Drawing and Animation

Pictures are Images of Colors, and the GPU draws them fast (see Graphics on the GPU). Around the pixels there's arithmetic every program that draws needs: boxes, natural-looking randomness, and motion that eases in and out.

Boxes

A Rect is a box with its sides along the axes - x and y its top-left corner, y growing downward as on an Image. containsPoint is the hit test (the left and top edges count, the right and bottom don't, so neighbouring boxes never both claim a point), intersects and intersection find overlaps, and Rect.around and union give bounding boxes. expand, translate and scale move and resize one.

Noise

Noise is Ken Perlin's improved noise: a value roughly between -1 and 1 for every point, changing smoothly as the point moves, and the same every time for the same seed - hills, clouds, a camera's wobble. Points on whole numbers are all 0, so sample between them, scaled to how fast it should change. fractal adds finer layers - each at twice the frequency and persistence times the strength - for rough detail on a smooth shape.

Easing

Motion at one speed looks mechanical. An Easing maps progress from 0 to 1 onto a curve: OutCubic starts fast and settles, InOutSine eases both ends, OutBack overshoots a little and comes back, OutBounce lands and bounces. apply(t) gives the eased progress, clamping t to 0..1 first, and between(from, to, t) the value that far along. They're the curves of easings.net and of CSS's named timing functions.