Munching squares: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Make the file names distinct so they don't overwrite each other) |
(Added AWK version) |
||
Line 30: | Line 30: | ||
end XorPattern;</lang> |
end XorPattern;</lang> |
||
{{out}} [[Image:AdaXorPattern.png|Ada Output|200px]] |
{{out}} [[Image:AdaXorPattern.png|Ada Output|200px]] |
||
=={{header|AWK}}== |
|||
{{works with|gawk}} |
|||
This program generates a PPM image, that you can view/convert using The GIMP or ImageMagick |
|||
<lang awk> |
|||
BEGIN { |
|||
# square size |
|||
s = 256 |
|||
# the PPM image header needs 3 lines: |
|||
# P3 |
|||
# width height |
|||
# max colors number (per channel) |
|||
print("P3\n", s, s, "\n", s - 1) |
|||
# and now we generate pixels as a RGB pair in a relaxed |
|||
# form "R G B\n" |
|||
for (x = 0; x < s; x++) { |
|||
for (y = 0; y < s; y++) { |
|||
p = xor(x, y) |
|||
print(0, p, p) |
|||
} |
|||
} |
|||
} |
|||
</lang> |
|||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |