rgb2.nv
· 982 B · Text
Ham
Playground
|--| Are we at the end of a line?
|eol?,x|x,~eol|eol?|eol
|--| Are we at the end of the screen?
|eos?,y|y,~eos|eos?|eos
|--| Copy the pixel coordinates from `x/y` to `@pixel-x/@pixel-y`.
|px=x,x|*x,@pixel-x,px=x
|px=x|
|py=y,y|*y,@pixel-y,py=y
|py=y|
|--| Compute some pixel colors based on the `x/y` coordinates.
|--| r = x, g = y, b = x + y
|pr=x,x|*x,@pixel-r,pr=x|pr=x|
|pg=y,y|*y,@pixel-g,pg=y|pg=y|
|pb=x+y,x|*x,@pixel-b,pb=x+y
|pb=x+y,y|*y,@pixel-b,pb=x+y
|pb=x+y|
|--| Copy temporaries back to their respective variables.
|*x|x|*y|y
|--| Plot a pixel.
|pp|px,py,pr,pg,pb,ps
|px|px=x:128
|py|py=y:128
|pr|pr=x:128
|pg|pg=y:128
|pb|pb=x+y:128
|ps|@set-pixel
|--| Move the `x/y` coordinates.
|x-,x||x-||y-,y||y-|
|--| Clear the previous color values before computing a new color.
|@pixel-r||@pixel-g||@pixel-b|
|--| Main loop.
||x:128,y:128
|f,eol,x|f,eol,f
|f,eol|f,eos?, @display
|f,~eol|pp,x-,f
|f,eos|pp,x:128,y:128
|f,~eos,x|f,~eos
|f,~eos|y-,x:128,f
|f|eol?,f
||f
1 | |--| Are we at the end of a line? |
2 | |eol?,x|x,~eol|eol?|eol |
3 | |
4 | |--| Are we at the end of the screen? |
5 | |eos?,y|y,~eos|eos?|eos |
6 | |
7 | |--| Copy the pixel coordinates from `x/y` to `@pixel-x/@pixel-y`. |
8 | |px=x,x|*x,@pixel-x,px=x |
9 | |px=x| |
10 | |py=y,y|*y,@pixel-y,py=y |
11 | |py=y| |
12 | |
13 | |--| Compute some pixel colors based on the `x/y` coordinates. |
14 | |--| r = x, g = y, b = x + y |
15 | |pr=x,x|*x,@pixel-r,pr=x|pr=x| |
16 | |pg=y,y|*y,@pixel-g,pg=y|pg=y| |
17 | |pb=x+y,x|*x,@pixel-b,pb=x+y |
18 | |pb=x+y,y|*y,@pixel-b,pb=x+y |
19 | |pb=x+y| |
20 | |
21 | |--| Copy temporaries back to their respective variables. |
22 | |*x|x|*y|y |
23 | |
24 | |--| Plot a pixel. |
25 | |pp|px,py,pr,pg,pb,ps |
26 | |px|px=x:128 |
27 | |py|py=y:128 |
28 | |pr|pr=x:128 |
29 | |pg|pg=y:128 |
30 | |pb|pb=x+y:128 |
31 | |ps|@set-pixel |
32 | |
33 | |--| Move the `x/y` coordinates. |
34 | |x-,x||x-||y-,y||y-| |
35 | |
36 | |--| Clear the previous color values before computing a new color. |
37 | |@pixel-r||@pixel-g||@pixel-b| |
38 | |
39 | |--| Main loop. |
40 | ||x:128,y:128 |
41 | |f,eol,x|f,eol,f |
42 | |f,eol|f,eos?, @display |
43 | |f,~eol|pp,x-,f |
44 | |f,eos|pp,x:128,y:128 |
45 | |f,~eos,x|f,~eos |
46 | |f,~eos|y-,x:128,f |
47 | |f|eol?,f |
48 | ||f |