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.
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.

"""
"""
c = tuple(map(lambda bg, fg: int(round(alpha * fg + (1-alpha) * bg)),
compose_color = lambda bg, fg: int(np.round(alpha * fg + (1-alpha) * bg))
img.getpixel(xy), color))
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(p(*p1)) + 1
xstart = draw_endpoint(p1) + 1
xend = draw_endpoint(p(*p2))
xend = draw_endpoint(p2)


for x in range(xstart, xend):
for x in range(xstart, xend):