paint

Android Paint: how to get “airbrush” effect?

一曲冷凌霜 提交于 2019-12-04 08:28:52
问题 I am following the "FingerPaint" demo in the API Demos. I would need to get an "airbrush" effect, in the sense that when I draw over the same spot it gets darker and darker. Please see the image: as you can see the center is darker because I passed with the paint on the same spot more than one time. Please how do I get the same effect, of getting darker a spot if drawn over more than one time? EDIT EDIT EDIT the suggested mPaint.setAlpha(0x80) kind of work, but only if I release touch and

Simulating brush strokes for painting application

喜夏-厌秋 提交于 2019-12-04 07:46:27
问题 I'm trying to write an application that can be used to create pictures that look like paintings using simulated brush strokes. Are there any good sources for simple ways of simulating brush strokes? For example, given a list of mouse positions that the user has dragged the mouse through, a brush width and a brush texture, how do I determine what to draw to the canvas? I've tried angling the brush texture in the direction of the mouse movement and dabbing several brush texture images along the

Dragging Image using MouseDrag method

こ雲淡風輕ζ 提交于 2019-12-04 07:09:57
问题 I'm trying to code where an image can be dragged using the mouseDragged method, but I can't seem to successfully do it with my current code. My aim is to ensure that when I place drag on every image in the applet, it follows the cursor. /* Using drag mouseEvent, all objects in the app can be dragged... */ package finals_two; import java.applet.*; import java.awt.*; import java.awt.event.*; /* 10/16/2015 * @author michael.pabilona */ public class Finals_Two extends Applet implements

Paint background of JPanel

 ̄綄美尐妖づ 提交于 2019-12-04 03:56:27
问题 How can I tell the paint method to draw background on JPanel only and not on the entire JFrame. My JFrame size is bigger than the JPanel. When I try to paint a grid background for the JPanel, the grid seems to be painted all over the JFrame instead of just the JPanel. Here parts of the code: public class Drawing extends JFrame { JPanel drawingPanel; ........... public Drawing (){ drawingPanel = new JPanel(); drawingPanel.setPreferredSize(new Dimension(600,600)); } public void paint(Graphics g

My overriden paint method is not getting called

若如初见. 提交于 2019-12-04 02:27:43
问题 I have a JPanel that is meant to act as a HUD for my game, naturally, I have overridden the paint method to do my own custom display, this does get called, but only upon resizing or maximizing, minimizing the frame, and not when my game loop tells it to repaint(). It seems particularly strange to me on account of my two other panels being repainted completely fine. Here is my HUD class: package base; import java.awt.Color; import java.awt.Graphics; import javax.swing.BoxLayout; import javax

Can you increase line thickness when using Java Graphics for an applet? I don't believe that BasicStroke works [duplicate]

拜拜、爱过 提交于 2019-12-04 00:40:35
This question already has an answer here: Java2D: Increase the line width 2 answers I am having trouble adjusting line thickness. Can I do that in Graphics or do i have to do it in Graphics2D? If so, how do I alter the program to make it run? Thanks! import java.applet.Applet; import java.awt.*; public class myAppletNumberOne extends Applet { public void paint (Graphics page) { //Something here??? } } Yes you have to do it in Graphics2D, but that's hardly an issue, as every Graphics in Swing is a Graphics2D object (it just keeps the old interface for compatibility reasons). public void

How to erase finger paint on Custom UIView in iPhone

走远了吗. 提交于 2019-12-03 22:32:58
问题 I have created a custom UIView (without .xib) for a finger paint application. Paint is working fine with custom UIView but my problem is that when I try to erase the painted path I am getting: Error : Invalid context Below is my class: .h file @interface draw2D : UIView { CGPoint previousPoint; CGPoint lastPoint; CGMutablePathRef path; UIButton *btnClose; UIButton *btnErase; BOOL IsErase; } - (IBAction)btnClose:(id)sender; - (IBAction)btnErase:(id)sender; @end @implementation draw2D - (void

Unity3D looking for setPixels example to paint with texture in C#

江枫思渺然 提交于 2019-12-03 21:42:02
I need to find a way that allow me to paint a gameObject using a texture, the goal is to make a clone of this game I already thought that i can fake the painting feature by using depthMask solution which i explained here , however, after many hours of research it seems that setPixels,setPixel and setPixels32 can be used to create a real painting but For some reason all the setPixels related topics at the Script Reference are in JavaScript, i tried to port it to c# but i always got errors, plus it's kind of a complicated approach and the script reference doesn't explain it very well, So am

How to draw signature with lines on iPhone screen?

点点圈 提交于 2019-12-03 21:08:13
I want to let user draw a signature on iPhone screen, so I add a subclass of UIView and add some code to its 'touchesMoved' method. -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; firstTouch = [touch locationInView:self]; CGSize mySize = CGSizeMake(5, 5); UIGraphicsBeginImageContext(mySize); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextBeginPath(ctx); CGContextSetRGBFillColor(ctx, 1, 0, 0, 1); CGContextAddRect(ctx, CGRectMake(0, 0, 5, 5)); CGContextFillPath(ctx); UIImage *redRect = UIGraphicsGetImageFromCurrentImageContext()

Tickmark algorithm for a graph axis

冷暖自知 提交于 2019-12-03 18:21:19
问题 I'm looking for an algorithm that places tick marks on an axis, given a range to display, a width to display it in, and a function to measure a string width for a tick mark. For example, given that I need to display between 1e-6 and 5e-6 and a width to display in pixels, the algorithm would determine that I should put tickmarks (for example) at 1e-6, 2e-6, 3e-6, 4e-6, and 5e-6. Given a smaller width, it might decide that the optimal placement is only at the even positions, i.e. 2e-6 and 4e-6