문제

As per my project requirement, I wanted to create a brush which will give me a effect like oil/water painting. Please find attached snaps of it. I've taken this snap from Microsoft Paint Application. Microsoft Paint provides different brushes and one of them is Oil Brush.

After keen observation, I noticed that the complete pattern used in microsoft paint is hard-coded. For every stoke(with any color) it gets repeated.

My requirement are flexible, either i can implement fixed brush style or it can be random pattern.

I wanted to know, which API to use so that my solid fill line will look like a oil paint or water color painting.

I've created a sample application which uses NSBezierPath to draw a path but NSBezierPath doesn't have any functionalities using which i can provide such effects to it.

Regards Omkar

도움이 되었습니까?

해결책

I solved it using NSColor class API

NSImage* anImage; // Create an image with any brush pattern
[[NSColor colorWithPatternImage:anImage]

I created a small image say 25x25 out of a oil paint brush pattern created in MS Paint application and provided the path to anImage object.

in drawRect before drawing the NSBezierPath I set the color using above image object.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top