::SHE+ILA:: draws the line [$67]

177
3
  • Squishy Plushie's avatar Artist
    Squishy Pl...
  • Prompt
    Read prompt
  • DDG Model
    DaVinci2
  • Access
    Public
  • Created
    1mo ago
  • Try

More about ::SHE+ILA:: draws the line [$67]

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

Comments


Loading Dream Comments...

Discover more dreams from this artist