Color

Represents a color and allows for calculations within the chosen color space.

new Color(p1: any, p2: any, p3: any, alpha: any, mode: any)
Parameters
p1 (any) {number} First component: Hue (0-360) or Red (0-255)
p2 (any) {number} Second component: Saturation (0-100) or Green (0-255)
p3 (any) {number} Third component: Luminosity (0-100) or Blue (0-255)
alpha (any = 1) {number} Alpha component (0-1), default = 100.
mode (any = null) {string} Color.RGB or Color.HSL
Static Members
HSL
RGB
hsl(hue, sat, lum, alpha)
rgb(red, green, blue, alpha)
BLACK
WHITE
TRANSPARENT
Instance Members
toStr()

Palette

Predefined palettes.

Palette
Static Members
Pico8

Circle

A drawable circle.

new Circle(x: any, y: any, r: any)

Extends Drawable

Parameters
x (any)
y (any)
r (any)
Static Members
fromPoints(pt1, pt2)
fromPoint(pt1, r)
Instance Members
nudge(dx, dy)
centroid()
sample(n)
scale(sx, sy)
radianPoint(rads)
lerp(t, behavior, Lerp)
radianArc(fromRad, toRad, long)

Arc

An Arc

new Arc(startX: any, startY: any, endX: any, endY: any, long: any, r: any)

Extends Drawable

Parameters
startX (any)
startY (any)
endX (any)
endY (any)
long (any)
r (any)
Instance Members
nudge(dx, dy)
centroid()
lerp(t, behavior, Lerp)

QuadraticBezier

Drawable representing a quadratic bezier path.

new QuadraticBezier(startX: any, startY: any, ctrlX: any, ctrlY: any, endX: any, endY: any)

Extends Drawable

Parameters
startX (any)
startY (any)
ctrlX (any)
ctrlY (any)
endX (any)
endY (any)
Instance Members
nudge(dx, dy)
lerp(t, behavior, Lerp)
centroid()

CubicBezier

Drawable representing a cubic bezier path.

new CubicBezier(startX: any, startY: any, ctrl1X: any, ctrl1Y: any, ctrl2X: any, ctrl2Y: any, endX: any, endY: any)

Extends Drawable

Parameters
startX (any)
startY (any)
ctrl1X (any)
ctrl1Y (any)
ctrl2X (any)
ctrl2Y (any)
endX (any)
endY (any)
Instance Members
nudge(dx, dy)
lerp(t, behavior, Lerp)
centroid()

Ellipse

A drawable ellipse.

new Ellipse(x: any, y: any, rx: any, ry: any)

Extends Drawable

Parameters
x (any)
y (any)
rx (any)
ry (any)
Instance Members
nudge(dx, dy)
scale(sx, sy)
centroid()
radianPoint(rads)
lerp(t, behavior, Lerp)
radianArc(fromRad, toRad, long)

Drawable

Base class for drawables.

Provides

new Drawable()
Instance Members
clone()
id(newId)
data(newData)
rotateRad(t)
rotateDeg(t)
sample(n)
randomSample(n)
draw(drawStyle, w)
animate(animFunc, context, w)

Selection

A selection of drawables that can be operated upon.

new Selection(items: any)

Extends Drawable

Parameters
items (any = null)
Instance Members
forEach(callback)
map(callback)
filter(predicate)
draw(drawStyle)
animate(animFunc)
collect()

RectGrid

Rectangular grid layout.

Divides a box into equally spaced rectangles.

new RectGrid(rows: any, cols: any, box: any)
Parameters
rows (any) {number} Number of rows in grid.
cols (any) {number} Number of columns in grid.
box (any = null) {Box} Box to subdivide, if not provided will use the world box.
Instance Members
boxHeight
boxWidth
box(row, col)
vline(n)
hline(n)
boxes()
lines()

HexGrid

Hexagonal grid layout.

new HexGrid(rows: any, cols: any, flatTop: any, box: any)
Parameters
rows (any)
cols (any)
flatTop (any)
box (any)

RadialPoints

Defines a radial layout with concentric circles, similar to a sunflower.

new RadialPoints(cx: any, cy: any, steps: any, rings: any, ringWidth: any)
Parameters
cx (any)
cy (any)
steps (any)
rings (any)
ringWidth (any)

Random

Static namespace for random helper functions.

new Random()
Static Members
chance(odds)
under(num)
between(lo, hi)
intBetween(lo, hi)
radians()
choice(array, Array)

Point

A single x,y point in Cartesian coordinates.

This value is interpreted relative to the world box.

new Point(x: any, y: any)

Extends Drawable

Parameters
x (any)
y (any)
Instance Members
centroid()
nudge(dx, dy)

Line

Represents a line connecting two points.

new Line(x1: any, y1: any, x2: any, y2: any)

Extends Drawable

Parameters
x1 (any)
y1 (any)
x2 (any)
y2 (any)
Instance Members
centroid()
nudge(dx, dy)
lerp(t, behavior)
pointA()
pointB()

Box

A box (rectangle).

All boxes are nested within a parent box with coordinates interpreted relative to that parent.

If no parent is specified, the "world box" is used, a box created when the library is initialized matching the worldBox

new Box(x: any, y: any, width: any, height: any, parent: any)

Extends Drawable

Parameters
x (any)
y (any)
width (any)
height (any)
parent (any = null)
Instance Members
nudge(dx, dy)
point(which)
lerp(t, behavior)
line(from, to)

Polygon

A Polygon represented as a set of points to be connected in a clockwise manner.

new Polygon(points: any)

Extends Drawable

Parameters
points (any)
Instance Members
nudge(dx, dy)

World

Base instance of a honeycomb drawing/animation.

Can be instantiated once to use global methods, or multiple times to have separate isolated rendering contexts.

new World(renderer: any, width: any, height: any)
Parameters
renderer (any)
width (any)
height (any)
Static Members
create(elemId, width, height, background, renderer)