I want to draw line, like chalk. And the line's edge is faint. Just like use chalk draw on blackboard.
How do I get this? Now, I had drawed line using image, but it doesn't look like draw on blackboard, because the line is not faint. Please, give me some suggestions.
Here is my code:
for (NSDictionary *dictStroke in self.arrayStrokes)
{
NSArray *arrayPointsInstroke = [dictStroke objectForKey:@"points"];
//UIColor *color = [dictStroke objectForKey:@"color"];
UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"point.png"]];
float size = [[dictStroke objectForKey:@"size"] floatValue];
[color setStroke]; // equivalent to both setFill and setStroke
// draw the stroke, line by line, with rounded joints
UIBezierPath* pathLines = [UIBezierPath bezierPath];
CGPoint pointStart = CGPointFromString([arrayPointsInstroke objectAtIndex:0]);
[pathLines moveToPoint:pointStart];
for (int i = 0; i < (arrayPointsInstroke.count - 1); i++)
{
CGPoint pointNext = CGPointFromString([arrayPointsInstroke objectAtIndex:i+1]);
[pathLines addLineToPoint:pointNext];
}
pathLines.lineWidth = size;
pathLines.lineJoinStyle = kCGLineJoinRound;
pathLines.lineCapStyle = kCGLineCapRound;
[pathLines stroke];
arraynum++;
}
Try to use a pattern image with zebra lines. That would give you the effect like chalk writing.
brushPattern = [[UIColor alloc]initWithPatternImage: [UIImage imageNamed:@"pattern.jpg"]];
- (void)drawRect:(CGRect)rect
{
[brushPattern setStroke];
[myPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0]; // myPath - points to be drawn
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With