Shape blocks are used to draw geometric primitives on the canvas. These blocks are typically used in the Playground section and are affected by effect blocks like fill, stroke, and transformations.
{ "name": "circle", "source": "original", "input": { "0": ["3", "1", "0"], // x position from bounce "1": ["3", "3", "0"], // y position from bounce "2": ["0", "1", "0"] // radius from slider }}
In context:
Line 5: [strokePicker: #4a90e2ff] // Set stroke color [fillRGBA] <-- x, y mapped to R, G values [circle] <-- x, y from bounce, radius from slider
The circle’s position is controlled by the bounce blocks, and its color is set by the effect blocks above it.
This example draws lines from canvas corners to the mouse position:
Line 4: [strokeRGBA] <-- random RGB colors [stopDraw] <-- if mouse not pressed [lineXY] <-- from (0, 0) to (mouseX, mouseY) [lineXY] <-- from (width, height) to (mouseX, mouseY)
When the mouse is pressed, two lines are drawn creating a dynamic X pattern following the cursor.
Line 0: [mouseIsPressed] -> booleanLine 1: [strokeRGBA] <- colors [stopDraw] <- if NOT mouseIsPressed, stop hereLine 2: [lineXY] <- only draws if mouse is pressed
Frame Rate: Drawing many shapes each frame can impact performance. The Playground runs at 60 FPS by default. Use frameRate block to adjust if needed.
Effect Block Range: Remember that effect blocks like fill and stroke affect all shapes that follow them on the same line or subsequent lines, until another effect block changes them.