Xiaolin Wu's line algorithm: Difference between revisions

Content deleted Content added
format code
m code spacing
Line 8:
'''function''' plot(x, y, c) '''is'''
plot the pixel at (x, y) with brightness c (where 0 ≤ c ≤ 1)
 
'''function''' ipart(x) '''is'''
'''return''' ''integer part of x''
 
'''function''' round(x) '''is'''
'''return''' ipart(x + 0.5)
 
'''function''' fpart(x) '''is'''
'''return''' ''fractional part of x''
 
'''function''' rfpart(x) '''is'''
'''return''' 1 - fpart(x)
 
'''function''' drawLine(x1,y1,x2,y2) '''is'''
 
'''if''' x2 < x1
swap x1, x2
swap y1, y2
'''end if'''
 
dx = x2 - x1
dy = y2 - y1