from PIL import Image def mid(x1,x2): return (x1+x2)/2 def calc_points(x0,x1,num_points): tab=[x0,x1,0] tab[2]=mid(tab[0],tab[1]) i=2 j=i while i< num_points+1: tab.append(mid(tab[j],tab[0])) tab.append(mid(tab[j],tab[1])) i=i+2 j=j+1 return tab def draw_line(start,end,image): x0,x1=(start[0],end[0]) y0,y1=(start[1],end[1]) # line length calculation num_points=max(abs(x1-x0),abs(y1-y0)) # calculate line points xtab=calc_points(x0,x1,num_points) ytab=calc_points(y0,y1,num_points) # plot to image for i in range(num_points): image.putpixel((int(xtab[i]),int(ytab[i])),0) image=Image.new("1",(320,200),"WHITE") draw_line((40,0),(100,33),image) image.show()

lda a clc adc b ror sta c

mid .macro lda \1+\2 clc adc \1+\3 ror sta \1+\4 .endm calcpoints j .var 2 i .var 0 .while i<256 #mid tab,0,j,i #mid tab,1,j,i i .var i+1 j .var j+2 .next

It could be handy for clipping or very flat or steep lines