Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
Artist
... without explicitly using the Bressenham (sp?) algorithm. Suppose we have two quaternions (groan) S and E, containing the projected corners of a bounding box defining the line. We compute the mean, in order to find the centre of the line, and then recursively draw two lines between the centre and each end. (I read this somewhere, I forget exactly where).
DrawLine <:: {(S=%1, E=%2, COLOUR=%3, CENTRE=(S $A E)) {
// Note: $A is the average (mean) operator, internally using right shifts and adds
PSet (CENTRE, COLOUR); // Put a pixel on the screen
(DrawLine (S, CENTRE, COLOUR), ()) [1+(S==CENTRE)];
(DrawLine (CENTRE, E, COLOUR), ()) [1+(E==CENTRE)];
}
Note: make sure your thread has a big stack, hehehe :)
The conditional expressions (foo, ()) [1+condition] are necessary to terminate the recursion when we hit S and E :)