tags:

views:

31

answers:

2

I have to draw a line between two points using quartz. At some point I have this code:

CGContextBeginPath(ctx);

CGContextMoveToPoint(ctx, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(ctx, currentPoint.x, currentPoint.y);
CGContextStrokePath(ctx);

This lines will create a hard line between the points currentPoint and lastPoint. The line is so hard, like done by stamping a square of pixels from one point to the other.

Can a bitmap be used (for example a little white blurred ball) to substitute this hard brush tip and create a softness on the line? I mean, create a soft line with blurred edges?

Obviously the little white blurred ball should be stamped along the path to accomplish this. Is that possible? How?

See the next picture. The left line is what the code does currently. The right line is what I would like to do.

alt text

thanks

+1  A: 

Using a bitmap image is unlikely to provide you with satisfactory drawing performance, as is any other quartz methods for drawing blurred lines real time. This will be a pain, but you should seriously consider using openGL. See Apple's GLPaint example.

Run Loop
+1  A: 

CGContextSetShadowWithColor with zero offset and the same shadow color as the stroke color may be close to what you need. To actually use a custom bitmap, you would have to manually evaluate the path and draw an image at each point.

drawnonward
thanks. This method gives me a little better result... not exactly what I need but better. I am not sure if stamping the image along the path will be fast enough for the app to continue light... I will try.
Digital Robot