-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Common methods have been pulled up into a BaseSketch class. It's dense, but most of the calls rely on private methods that extend the PApplet class. User sketches should extend the BaseSketch class and override settings, setup and draw. The draw method in the user defined sketch should call postDraw at the end of its render calls. This masks content that overflows the canvas, and draws debug information overtop the sketch. If the debug interface or any other elements aren't rendering correctly, it's likely due to a missing postDraw call.
The canvas padding is dictated by the CANVAS_PERCENTAGE variable (with a default of .85 of available applet space being filled by the canvas).
The contents of the canvas are rendered via a simple camera simulation. The initial view of the canvas' camera is centered at (0, 0) and as a 1:1 aspect ratio and a 1 unit viewport.
The variables in BaseSketch prefaced with GRID_*, dictate the position, and bounds of the viewport.
GRID_WIDTH
GRID_HEIGHT
GRID_MID_X
GRID_MIX_Y
GRID_LOWER_X
GRID_UPPER_X
GRID_LOWER_Y
GRID_UPPER_Y
The methods
drawWorldRect
drawWorldEllipse
drawWorldLine
drawWorldText
Will draw primitives within the canvas.
Additionally, there is a utility Polygon class which allows for quick generation and modification of complex Polygons. All of the setters on the Polygon class return a self reference, so that they may be chained:
polygons.add(Polygon
.generate(0, 0, 0.075f, 8)
.scale(1, 2)
.tag("cursor")
.rotate(90));
The static generate method, used above, creates a new Polygon at pos (0, 0), with a radius of 0.075f, and 8 edges.
Polygons can also be tagged using the var-args tag setter. Conversely, you can check for the presence of a tag in a Polygon's tag list using its hasTag() method.