Xiaolin Wu's line algorithm: Difference between revisions

Content added Content deleted
Line 1,551: Line 1,551:
{{trans|Scheme}}
{{trans|Scheme}}


The program outputs a transparency mask in Portable Gray Map format.
The program outputs a transparency mask in Portable Gray Map format. It draws lines normal to a tractrix. They trace out a catenary.

<syntaxhighlight lang="lisp">
<syntaxhighlight lang="lisp">
;;; The program outputs a transparency mask in plain Portable Gray Map
;;; The program outputs a transparency mask in plain Portable Gray Map
Line 1,715: Line 1,716:
;;;-------------------------------------------------------------------
;;;-------------------------------------------------------------------
</syntaxhighlight>
</syntaxhighlight>

Here is a script to run the program and produce a PNG image.
<syntaxhighlight lang="sh">
#!/bin/sh

sbcl --script xiaolin_wu_line_algorithm.lisp > alpha.pgm
pamgradient black black darkblue darkblue 800 800 > bluegradient.pam
pamgradient red red magenta magenta 800 800 > redgradient.pam
pamcomp -alpha=alpha.pgm redgradient.pam bluegradient.pam | pamtopng > image.png
</syntaxhighlight>

{{out}}
[[File:Xiaolin wu line algorithm CommonLisp.png|thumb|none|alt=A catenary as the evolute of a tractrix. Reddish gradient on bluish gradient.]]


=={{header|D}}==
=={{header|D}}==