3

In my little project I have a function that returns a list of points coordinates. Like this:

    points = [(x1, y1), (x2, y2),...]

When I draw it on image, I get points on image but I want continious line. How can I get it? And how to draw interpolated lines on an image?

milssky
  • 143
  • 7

1 Answers1

3

To draw lines, do the following:

import Image
import ImageDraw

im = Image.new('RGB',(500,500),(255,255,255))
draw = ImageDraw.Draw(im)
draw.line(points, fill=(255,0,0))
del draw 
im.save('output.jpg')

Once you understand the above code you'll be able to use the answers in this question to draw antialiased lines.

Community
  • 1
  • 1
carlosdc
  • 11,578
  • 3
  • 38
  • 60
  • Yes, it works but line isn't smooth. I see some pixels. I want to do spline interpolation but i don't know how do it. :) – milssky Apr 08 '13 at 20:56
  • 1
    @milssky: I've added a link to several alternatives to how to draw antialiased lines with PIL. – carlosdc Apr 09 '13 at 00:19