rgb400_ungolfed
· 1.4 KiB · Text
Raw
Playground
|--| Are we at the end of a line?
|end of line?, x| x, ~end of line
|end of line?| end of line
|--| Are we at the end of the screen?
|end of screen?, y| y, ~end of screen
|end of screen?| end of screen
|--| Copy the pixel coordinates from `x/y` to `@pixel-x/@pixel-y`.
|pixel_x=x, x|*x, @pixel-x, pixel_x=x
|pixel_x=x|
|pixel_y=y, y|*y, @pixel-y, pixel_y=y
|pixel_y=y|
|--| Compute some pixel colors based on the `x/y` coordinates.
|--| r = x, g = y, b = x + y
|pixel_red=x, x| *x, @pixel-r, pixel_red=x
|pixel_red=x|
|pixel_green=y, y| *y, @pixel-g, pixel_green=y
|pixel_green=y|
|pixel_blue=x+y, x| *x, @pixel-b, pixel_blue=x+y
|pixel_blue=x+y, y| *y, @pixel-b, pixel_blue=x+y
|pixel_blue=x+y|
|--| Copy temporaries back to their respective variables.
|*x|x
|*y|y
|plot_pixel| pixel_x, pixel_y, pixel_red, pixel_green, pixel_blue, set pixel
|pixel_x| pixel_x=x:399
|pixel_y| pixel_y=y:399
|pixel_red| pixel_red=x:399
|pixel_green| pixel_green=y:399
|pixel_blue| pixel_blue=x+y:399
|set pixel| @set-pixel
|--| Move the `x/y` coordinates.
|x-,x|
|x-|
|y-,y|
|y-|
|--| Main loop.
|draw, end of line, x| draw, end of line, draw
|draw, end of line| draw, end of screen?, @display
|draw, ~end of line| plot_pixel, x-, draw
|draw, end of screen| plot_pixel, x:399, y:399
|draw, ~end of screen, x| draw, ~end of screen
|draw, ~end of screen| y-,x:399, draw
|draw| end of line?, draw
|--| clean up remaining facts
|x|
|y|
|--| run the program
||x:399,y:399
||draw
1 | |--| Are we at the end of a line? |
2 | |end of line?, x| x, ~end of line |
3 | |end of line?| end of line |
4 | |
5 | |--| Are we at the end of the screen? |
6 | |end of screen?, y| y, ~end of screen |
7 | |end of screen?| end of screen |
8 | |
9 | |--| Copy the pixel coordinates from `x/y` to `@pixel-x/@pixel-y`. |
10 | |pixel_x=x, x|*x, @pixel-x, pixel_x=x |
11 | |pixel_x=x| |
12 | |pixel_y=y, y|*y, @pixel-y, pixel_y=y |
13 | |pixel_y=y| |
14 | |
15 | |--| Compute some pixel colors based on the `x/y` coordinates. |
16 | |--| r = x, g = y, b = x + y |
17 | |pixel_red=x, x| *x, @pixel-r, pixel_red=x |
18 | |pixel_red=x| |
19 | |
20 | |pixel_green=y, y| *y, @pixel-g, pixel_green=y |
21 | |pixel_green=y| |
22 | |
23 | |pixel_blue=x+y, x| *x, @pixel-b, pixel_blue=x+y |
24 | |pixel_blue=x+y, y| *y, @pixel-b, pixel_blue=x+y |
25 | |pixel_blue=x+y| |
26 | |
27 | |--| Copy temporaries back to their respective variables. |
28 | |*x|x |
29 | |*y|y |
30 | |
31 | |plot_pixel| pixel_x, pixel_y, pixel_red, pixel_green, pixel_blue, set pixel |
32 | |pixel_x| pixel_x=x:399 |
33 | |pixel_y| pixel_y=y:399 |
34 | |pixel_red| pixel_red=x:399 |
35 | |pixel_green| pixel_green=y:399 |
36 | |pixel_blue| pixel_blue=x+y:399 |
37 | |set pixel| @set-pixel |
38 | |
39 | |--| Move the `x/y` coordinates. |
40 | |x-,x| |
41 | |x-| |
42 | |y-,y| |
43 | |y-| |
44 | |
45 | |--| Main loop. |
46 | |draw, end of line, x| draw, end of line, draw |
47 | |draw, end of line| draw, end of screen?, @display |
48 | |draw, ~end of line| plot_pixel, x-, draw |
49 | |draw, end of screen| plot_pixel, x:399, y:399 |
50 | |draw, ~end of screen, x| draw, ~end of screen |
51 | |draw, ~end of screen| y-,x:399, draw |
52 | |draw| end of line?, draw |
53 | |
54 | |--| clean up remaining facts |
55 | |x| |
56 | |y| |
57 | |
58 | |--| run the program |
59 | ||x:399,y:399 |
60 | ||draw |
61 |