views:

254

answers:

1

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:

  1. Create the path you want to fill or stroke.
  2. 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 a CGImage and use CGContextDrawImage() to draw it into the graphics context provided by the callback function.
  3. Call CGContextSetFillColorSpace() or CGContextSetStrokeColorSpace() with CGColorSpaceCreatePattern() to set a pattern color space (necessary for the next step).
  4. Call CGContextSetFillPattern() or CGContextSetStrokePattern() to tell Quartz to use your pattern for filling/stroking.
  5. Call CGContextDrawPath() to draw the path.

Refer to the docs for more info on all these functions.

Ole Begemann
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