The images are generated in a reverse polish notation stack expression. The expression is calculated for every pixel in the image, with x and y indicating the current pixel location within the image. The codes that stackie understands are:
x : push x (x is in range 0...1)
y : push y (y is in range 0...1)
0...9 : push constant 0...9
P : push PI
d : duplicate top item on the stack
: : swap top two items on the stack
; : swap top and third items on the stack
s : sin
c : cos
q : sqrt
~ : abs
! : flip 1-a implemented as push(1-pop())
# : round to nearest integer
? : threshold ( value<=0 becomes 0, value>0 becomes 1 );
p : perlin noise (using top two stack values)
w : wraparound perlin noise using three stack valuesx,y,size
W : wraparound perlin noise using 4 stack values x,y,x_size, y_size
a : atan2
+ : add
- : subtract
* : multiply
/ : divide
^ : pow
> : max
< : min
While the final strings can look incomprehensible, writing a texture code is easier than it seems. You can build it up by constructing simple pieces and mixing them together
x | y |
x! | y! |
xy* | xy+2/ |
xyp | x8*y8*p1+2/ |
x9^ | y9^ |
x9^ y9^ + | x9^ y9^ + x!9^ y!9^ + + |
By combining simple sequences together you can construct more complex images.
x8* y3* p 1+ | x9^ x!9^ + y! + + |
x8* y3* p 1+ x9^ x!9^ + y! + - | Palette xy!1+* |
Stackie is on github
No comments:
Post a Comment