Postcarts are tiny DragonRuby programs that fit within 300 characters. They're a creative challenge that combines programming and art!
Every postcart starts with the TICK block - this is where your animation code goes:
TICK { |args| # Your code here }
The postcart canvas is 160x90 pixels
sld!(x, y) - Draw a 1x1 pixel at (x,y)sld!(x, y, w, h) - Draw a rectanglesld!(x, y, [r,g,b]) - Draw a colored pixelsld!(x, y, w, h, [r,g,b]) - Draw a colored rectangleslds! - Batch draw multiple shapes: slds!([x1,y1], [x2,y2,w,h], [x3,y3,[r,g,b]])bg!(r,g,b) - Set background colorcolor(n) - Use predefined palette color (0-31)pal - Access the full color palettesin(degrees) / cos(degrees) - Trig functions using degreessin_r(radians) / cos_r(radians) - Trig functions using radianstc - Get current tick count (useful for animations)scene!(w, h, scale) - Set canvas size and scaleno_clr! - Disable auto-clearing (for trails effect)pixels! - Switch to pixel rendering modeTICK{ bg! 0 64.times{|i| x=Math.sin(i*15+tc)*20+80 y=Math.cos(i*15+tc)*20+45 sld! x,y,[255,i*4,255-i*4] } }
This creates a colorful spinning circle animation!
tc shorthand for tick countcolor(n)