Xiaolin Wu's line algorithm: Difference between revisions

Content added Content deleted
Line 3,445: Line 3,445:
END Xiaolin_Wu_Task.
END Xiaolin_Wu_Task.
</syntaxhighlight>
</syntaxhighlight>

Here is a shell script that compiles the program, runs it, and (using Netpbm commands) makes a PNG using the outputted mask.

<syntaxhighlight lang="sh">
#!/bin/sh

# Set GM2 to wherever you have a GNU Modula-2 compiler.
GM2="/usr/x86_64-pc-linux-gnu/gcc-bin/13/gm2"

${GM2} -g -fbounds-check -fiso xiaolin_wu_line_algorithm_Modula2.mod
./a.out > alpha.pgm
ppmmake rgb:5C/06/8C 600 400 > bg.ppm
ppmmake rgb:E2/E8/68 600 400 > fg.ppm
pamcomp -alpha=alpha.pgm fg.ppm bg.ppm | pamtopng > image.png
</syntaxhighlight>

{{out}}
[[File:Xiaolin wu line algorithm Modula2.png|thumb|none|alt=A parabola, and lines normal to the parabola, forming a semicubic parabola as their envelope. A shade of yellow on a background shade of purple.]]


=={{header|Nim}}==
=={{header|Nim}}==