Reputation: 1241
I'm creating an ios drawing app and would like to understand how to rotate the texture I'm using for drawing to have the texture follow the direction of my stroke.
Sketchbook for iOS and brushes are two apps that Ive seen accomplish this.
Does anyone have any idea of how to achieve this?
Here's an example of the concept that I'm trying to capture: http://drawsketch.about.com/od/learntodraw/ss/pencilshading_5.htm
Attached is a screenshot from the sketchbook app of this in practice.
UPDATE:
I was able to figure this out (thanks to SO community for helping out!) and posted my answer here: https://stackoverflow.com/a/11298219/111856
Upvotes: 1
Views: 211
Reputation: 26345
You can just rotate the brush texture as you're drawing it. You can get the angle by taking the arctangent of the y delta divided by the x delta for each segment of the stroke:
atan2(newY - prevY, newX - prevX);
Then rotate your brush texture by that amount before blending it at each point along the line.
Upvotes: 1