iphone - can a bitmap be stamped in a path in quartz?
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.
thanks
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.
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.
精彩评论