ref: 6269c4d47ad98829dc716583a834406e2394ee73 bitart/README.md -rw-r--r-- 2.7 KiB
6269c4d4Evan Johnston add defaults to switch statements to silence warnings 9 months ago

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 for each pixel, which is colored depending on whether the result is 0, or if in gradient mode, directly based on the result. in color mode, the program is run once per channel, per pixel.