I want to make a path that has a png as it's pattern, or if you could or think it would be easier to make my own pattern, then tell me that also. I will be greatful to anyone who can put up some code. Thanks in advance
+1
A:
I don't know if I understand your question correctly. Are you trying to fill or stroke the path with the pattern? I guess the way to go is:
- Create the path you want to fill or stroke.
- Create a pattern with
CGPatternCreate()
. This function takes a lot of parameters, among them a pointer to a drawing callback function that will be called whenever the pattern is used. So you would place your code to draw the PNG image in this function. Create aCGImage
and useCGContextDrawImage()
to draw it into the graphics context provided by the callback function. - Call
CGContextSetFillColorSpace()
orCGContextSetStrokeColorSpace()
withCGColorSpaceCreatePattern()
to set a pattern color space (necessary for the next step). - Call
CGContextSetFillPattern()
orCGContextSetStrokePattern()
to tell Quartz to use your pattern for filling/stroking. - Call
CGContextDrawPath()
to draw the path.
Refer to the docs for more info on all these functions.
Ole Begemann
2009-12-16 01:24:40
Ok sorry, what I meant by the question was that i want to stroke the path with a pattern that looks like chalk, now I just don't know how to use CGPatternCreate to make a pattern containing a .png. I hope that answers your inquiry.
Jaba
2009-12-16 04:08:54