-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing colour/width affects previous paths #9
Comments
I have tried experimenting with storing path/colour/width for all paths in an array and adding them all to the context in drawRect. Each touchesEnded pushes the current path onto the stack and starts a new path ready for the next drawing. This works fine for being able to have lots of lines of different widths and colours. It slows slightly when there are loads of paths as you'd expect so maybe rasterizing is still the answer. This would also allow basic eraser functionality by using the clear blend mode on that combined image. I wonder if having a UIImageView subview (or indeed extending UIImageView) and writing down to that in drawInRect might be a solution. I guess the issue is that each drawInRect call would need to write on top of the current image, most likely meaning it needs to be drawn into the context repeatedly, causing performance issues. |
I did it with a mutable array of paths, it doesn't seem to slow things down that bad. I'll try to put it up on github |
I look forward to the updated code on github. |
@andsmi , could you please put your code changes to github |
@andsmi Could you share your code for the mutable array of paths please? |
This is a really great project and performs very well even on Retina iPad displays.
If you change the lineColor or lineWidth property and then attempt to draw another line, any previous paths that fall within the rectangle drawn in drawRect are updated to the new colour/width.
This makes sense since all drawn paths are added to the single mutable path but it's not ideal. I've been wondering about saving existing paths in onTouchesEnded but I'm not sure what is best to save to - UIImage, a sub-view or maybe a CGLayer.
The text was updated successfully, but these errors were encountered: