Skip to content
Apexify.jsDocs
Apexify.js version v5.4.5

Node / Images Shapes · reference

Shapes — every ShapeType & ShapeProperties

Current Apexify.js 6.0.0 documentation for Shapes — every ShapeType & ShapeProperties.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Vector shapes are drawn through the same createImage pipeline as bitmaps: set source to a ShapeType string and put geometry/styling under shape?: ShapeProperties.


Quick usage

SOURCEtypescript
typescript
Studio
await painter.createImage(  {    source: 'star',    x: 40,    y: 40,    width: 180,    height: 180,    shape: {      fill: true,      color: '#f59e0b',      outerRadius: 70,      innerRadius: 28,    },    stroke: { color: '#1f2937', width: 3 },    shadow: { color: '#00000066', offsetX: 4, offsetY: 6, blur: 12 },  },  buffer);

Required layer fields x and y always anchor the layout rectangle. Most primitives derive geometry from width / height (defaults 100 each when omitted).


Shape catalogue (ShapeType)

ShapeTypeLayout boxMain shape fields
rectangleFull width × heightfill, color, gradient
squareSide = min(width, height) from (x, y)Same as rectangle
circleEllipse inscribed in boxradius (defaults to min(w,h)/2), color, gradient
triangleUp-pointing trianglecolor, gradient
trapeziumIsosceles trapezoidcolor, gradient
star5-point star centred in boxouterRadius, innerRadius (optional; defaults scale from box)
heartHeart fitting the boxcolor, gradient
polygonRegular polygon or custom pathsides (default 6) or points
arcArc / annulus sectorcenterX, centerY, radius / outerRadius, innerRadius, startAngle, endAngle (radians)
pieSliceSame geometry path as arcUse innerRadius: 0 for a filled wedge

ShapeProperties reference

FieldApplies toRole
fillAllfalse skips fill() (outline-only useful with stroke)
colorAllFill colour when gradient is omitted
gradientAllGradient fill (gradient type from apexify.js)
radiuscircleOverrides automatic radius
outerRadius / innerRadiusstar, arc, pieSliceStar tips/valleys; arc outer/inner radii
sidespolygon (regular mode)Number of vertices (default 6)
pointspolygon (custom mode){ x, y }[] — canvas-absolute coordinates (see below)
centerX / centerYarc, pieSliceArc centre (default: centre of layout box)
startAngle / endAnglearc, pieSliceRadians; default full turn 0 → 2π

Important behaviour notes

  1. star is always 5 points; shape.points is not used for stars.
  2. Custom polygon.points are absolute canvas coordinates — they are not interpreted as offsets from x, y. Omit points to get a regular polygon centred in the layout box.
  3. arc vs pieSlice share the same implementation: with innerRadius > 0 you get an annulus sector; with innerRadius omitted or 0, the path includes the centre (pie wedge).
  4. Shape layers support filters, shadow, stroke, boxBackground, borderRadius, and borderPosition from the parent ImageProperties, but they do not use the bitmap-only features mask, distortion, meshWarp, clipPath, effects, filterOrder, or filterIntensity (see Paint order).
  5. Shadows: heart and star use a shape-aware shadow path; other shapes use the rectangular shadow for the layout box.

More examples

Regular hexagon

SOURCEtypescript
typescript
Studio
{  source: 'polygon',  x: 50,  y: 50,  width: 200,  height: 200,  shape: { color: '#6366f1', sides: 6 },}

Custom polygon (absolute vertices)

SOURCEtypescript
typescript
Studio
{  source: 'polygon',  x: 0,  y: 0,  width: 400,  height: 400,  shape: {    color: '#10b981',    points: [      { x: 200, y: 60 },      { x: 320, y: 320 },      { x: 80, y: 320 },    ],  },}

Donut arc segment

SOURCEtypescript
typescript
Studio
{  source: 'arc',  x: 0,  y: 0,  width: 300,  height: 300,  shape: {    color: '#f472b6',    startAngle: 0,    endAngle: Math.PI,    outerRadius: 120,    innerRadius: 70,    centerX: 150,    centerY: 150,  },}

Next steps