Brush Size

Dec 8, 2010 at 12:46 AM
Edited Dec 8, 2010 at 2:14 AM

Hey. I'm trying to create a paint brush type effect, where the user can draw on a writeablebitmap in real time. I came across this library and it looks great! Could anyone please suggest how I'd go about drawing a brush stroke? I've got the pixel coordinates X and Y, but I'm not sure how to specify the width of the brush. Thanks for the help. I should add, I'm using wb.DrawLine() which is working perfectly, but it's too thin. Is there a way to increase the size of this?

Dec 8, 2010 at 7:39 PM

You could use draw rectangle if you wanted to draw a thicker line, or are you looking for the line to look like an actual paint stroke?

Dec 9, 2010 at 9:17 PM

I tried this (in the MouseMove event):

wb.FillRectangle(prevX, prevY, (int)e.StylusDevice.GetStylusPoints(image1)[0].X, (int)e.StylusDevice.GetStylusPoints(image1)[0].Y, Colors.Red); 

but I get ArgumentOutOfRangeException after a few strokes.

Dec 14, 2010 at 11:29 AM

That looks like a problem with the

(int)e.StylusDevice.GetStylusPoints(image1)[0].X or (int)e.StylusDevice.GetStylusPoints(image1)[0].Y

lines, although its hard to tell without seeing a project.

 

Mar 30, 2011 at 6:00 PM
LiamB wrote:

You could use draw rectangle if you wanted to draw a thicker line, or are you looking for the line to look like an actual paint stroke?


Hi, I am using this with WP7 project and am also trying to figure out how to make the line thick.

I did try it earlier to use draw rectangle thought it wasn't very successful. Maybe i was doing it wrong as well. Let me try again... i have been messing about with code to try add it to the base DrawLine Method.

 

 

Apr 1, 2011 at 11:04 AM

I have managed to sort the issue out by a bit of cheating :)

I overloaded the DrawLine method and called it DrawThickLine which takes additional parameter called radius.

The drawline code is almost as is except the point where the pixel is painted. Instead of painting the pixel, i draw a filled ellipse at each x1, y1 computed and that does the job.

Is it worth adding to the library considering it probably is not as fast as original DrawLine ??