polygon
A regular polygon with any number of sides.
polygon(x: Val, y: Val, radius: Val, sides: Val): Expr
Import shape from shaders/std and use shape.polygon.
radius is the distance from the centre to the middle of each side (not to the corners), in uv. sides is the side count, 3 for a triangle and up. A flat side faces right at rotation 0.
Parameters
| Name | Type | Notes |
|---|---|---|
x | Val | |
y | Val | |
radius | Val | |
sides | Val |
Example
shape: {distance: ({x, y}, u) => polygon(x, y, u('radius'), u('sides')), …}
Tip.
math.mix(polygon(…), circle(…), u('rounding'))morphs the corners away.
See also
star— A star with straight sides and sharp points.flower— A flower with pointed petals and V-shaped valleys between them.circle— A circle of a given radius.