Xiaolin Wu's line algorithm: Difference between revisions
Content added Content deleted
(Bugfix) |
|||
Line 2,729: | Line 2,729: | ||
def putpixel(img, xy, color, alpha=1): |
def putpixel(img, xy, color, alpha=1): |
||
⚫ | |||
Paints color over the background at the point xy in img. |
|||
⚫ | |||
Use alpha for blending. alpha=1 means a completely opaque foreground. |
Use alpha for blending. alpha=1 means a completely opaque foreground. |
||
""" |
""" |
||
compose_color = lambda bg, fg: int(np.round(alpha * fg + (1-alpha) * bg)) |
|||
c = compose_color(img.getpixel(xy), color, alpha) |
|||
img.putpixel(xy, c) |
img.putpixel(xy, c) |
||
Line 2,763: | Line 2,762: | ||
return px |
return px |
||
xstart = draw_endpoint( |
xstart = draw_endpoint(p1) + 1 |
||
xend = draw_endpoint( |
xend = draw_endpoint(p2) |
||
for x in range(xstart, xend): |
for x in range(xstart, xend): |