5

I would like to make a pencil stroke in an iPhone application, which can draw lines such as you can see in this picture:

enter image description here

Can anybody show me how I could implement these types of stroke?

Baby Groot
  • 4,637
  • 39
  • 52
  • 71
Mashhadi
  • 3,004
  • 3
  • 46
  • 80
  • http://stackoverflow.com/questions/4172107/draw-lines-and-fills-with-a-chalk-texture-in-iphone-app – Yama Jan 31 '12 at 07:33

2 Answers2

4

There are no built-in functions for drawing this kind of stroke. You will have to come up with your own texture image and draw it repeatedly along the path. There are no built-in functions for getting points along a path either.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • one thing more, if i work in this way then it will not change its color from color palet – Mashhadi Jan 31 '12 at 08:16
  • 2
    Indeed. You need to make the texture image be a grayscale image. At each point where you want to paint the texture, you need to set it as the clipping mask, then fill its bounding box with your desired color. – rob mayoff Jan 31 '12 at 08:57
1

There are different ways to obtain what you're looking for... Probably the best solution (and more complicated) is using OpenGL ES.

Try to take a look at this sample code: http://developer.apple.com/library/ios/#samplecode/GLPaint/Introduction/Intro.html

Giuseppe Garassino
  • 2,272
  • 1
  • 27
  • 47