Xiaolin Wu's line algorithm: Difference between revisions

Line 2,317:
 
=={{header|ObjectIcon}}==
The program puts up a window. In the window you can draw a line by left-mouse-button-pushpress for one endpoint, and then right-mouse-button-pushanother press for the other endpoint. You can draw multiple lines. When you leave (by pressing "q", for instance, or closing the window), the program stores the image as a PNG.
 
Rather than vary the color as such, I vary the opacity.
Line 2,330:
local width, height
local done, w, event
local x1, y1, x2, y2, press_is_active
 
width := 640
Line 2,340:
set_canvas("normal") | stop(&why)
 
press_is_active := &no
done := &no
while /done do
Line 2,351 ⟶ 2,352:
Mouse.LEFT_PRESS:
{
x1if :=/press_is_active event[2]; y1 := event[3]then
} {
x1 := event[2]; y1 := event[3]
Mouse.RIGHT_PRESS:
{ press_is_active := &yes
x2 := event[2]; y2 := event[3]}
draw_line (w, x1, y1, x2, y2)else
{
x2 := event[2]; y2 := event[3]
draw_line (w, x1, y1, x2, y2)
press_is_active := &no
}
}
}
1,448

edits