that was just a straight up lie
add defaults to switch statements to silence warnings
i hate c
i got nerdsniped by https://botsin.space/@bitartbot into writing this
bitart [-g] [-c] [-i] [-w width] [-h height] [-s size] [-o out.png] program
flag | effect |
---|---|
-w | set the width |
-h | set the height |
-s | set both the width and the height |
-o | set the filename to output to (stdout by default) |
-g | enable gradient mode |
-c | enable color |
-i | invert (does not have effect when combined with -g) |
bitart -o xor_mod9.png "x y ^ 9 %"
bitart -o or_mod7.png "x y | 7 %"
bitart -o stripes.png -s 1024 'x#y#*y100/1+%'
the program is an rpn formula in a little stack based language with the operators
operator | input | output |
---|---|---|
^ | a b | a bitwise xor b |
| | a b | a bitwise or b |
& | a b | a bitwise and b |
~ | a | bitwise not a |
! | a | logical not a |
# | a | number of 1 bits in a |
+ | a b | a plus b |
/ | a b | a divided by b |
- | a b | a minus b |
* | a b | a times b |
% | a b | a modulo b |
e | a b | a to the power of b |
= | a b | 1 if a is equal to b, else 0 |
> | a b | 1 if a is greater than b, else 0 |
< | a b | 1 if a is less than b, else 0 |
x | the x value of the current pixel | |
y | the y value of the current pixel | |
h | the height of the image | |
w | the width of the image | |
s | a b | b a |
d | a | a a |
l | a b | a shifted left b places |
r | a b | a shifted right b places |
literal n | n |
the program is evaluated once for each pixel, which is colored based on the bottom most value left on the stack, either by comparing it to 0, or, in gradient mode, directly. in color mode the bottom most three values are used for the three color channels.