Ngon
A mesh that creates regular polygons with a configurable number of sides.
Ngon (N-gon) can create any regular polygon from triangles to circles. The shape is centered at its anchor point (default 0.5, 0.5) with vertices evenly distributed around the perimeter.
Common shapes by side count:
- 3: Triangle
- 4: Square (rotated 45°)
- 5: Pentagon
- 6: Hexagon
- 8: Octagon
- 32+: Circle approximation
The first vertex is positioned at (radius, 0) relative to center, with subsequent vertices placed counter-clockwise.
// Create a hexagon
var hexagon = new Ngon();
hexagon.sides = 6;
hexagon.radius = 40;
hexagon.color = Color.YELLOW;
// Create a smooth circle
var circle = new Ngon();
circle.sides = 64;
circle.radius = 50;
circle.color = Color.WHITE;
// Animated shape morphing
var morph = new Ngon();
morph.radius = 30;
morph.color = Color.PINK;
app.onUpdate(this, delta -> {
morph.sides = Math.round(3 + Math.sin(Timer.now) * 3);
});
Instance Members
sides: IntNumber of sides for the polygon.
Minimum 3 for a triangle. Higher values create smoother shapes that approximate a circle.
Default: 32 (smooth circle approximation)
radius: FloatRadius of the polygon in pixels.
Distance from center to vertices. The total size will be radius * 2 in both width and height.
Default: 50
computeContent(): VoidGenerates the polygon mesh geometry.
Creates a fan of triangles from the center point to vertices distributed evenly around the perimeter. The first perimeter vertex is at angle 0 (right side).
new(): VoidCreates a new N-gon polygon.
The shape is anchored at its center (0.5, 0.5) by default, making rotation and scaling behave naturally.
Private Members
Metadata
| Name | Parameters |
|---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |