yoshida yoshida
Open the editor

Docs Format Layers

Layer: polygon

On this page

A shape through a list of points: a triangle, a banner, a star, or an open line with arrowheads. Or a preset shape (star, polygon, arrow, ...) in a box.

{
  "id": "corner",
  "type": "polygon",
  "points": [[0, 0], [180, 0], [0, 190]],
  "fill": "with_alpha(accent, 0.8)",
  "stroke": { "color": "#FFFFFF", "width": 2 }
}

Plus the fields every layer has.

FieldKindDefaultMeaning
pointsarray of [x, y]required unless shape is givenAbsolute canvas coordinates (inside a translated group, relative to its origin)
closedbool literaltruefalse draws an open line through the points
fillcolor#FFFFFFFFIgnored when the polygon is not closed
stroke{ color, width, dash, arrow }nonecolor defaults to opaque black, width to 1. dash as for rect. arrow: see below
shape{ type, count, inner }noneA preset shape that fills box, instead of points
box{ x, y, w, h }Only with shape
  • A closed polygon needs at least 3 points, an open one at least 2 (error 1109). A point that is not a two-item array is error 1103.
  • Points are absolute canvas coordinates; anchor does not apply to them.
  • Every coordinate is an expression, so polygons scale with params: [["10%", 0], ["canvas.w - 40", "height * 0.5"]]. The first value of a point is a horizontal coordinate (% is a percentage of the canvas width), the second a vertical one.
  • closed must be the literal true or false, not an expression.
  • rotate turns a polygon with points around the centre of its bounds.
  • Stroke joins and line ends are round.

Arrowheads

On an open polygon, "arrow": "end" (or "start", "both") in the stroke draws arrowheads at the ends, 4 times the stroke width long. The line stops at the base of the head. Arrowheads only apply to polygons (error 1101 elsewhere).

{ "id": "link", "type": "polygon", "closed": false,
  "points": [["@a.bounds.cx", "@a.bounds.bottom"], ["@b.bounds.cx", "@b.bounds.top"]],
  "stroke": { "color": "#D1495B", "width": 4, "dash": [10, 6], "arrow": "end" } }

Preset shapes

With shape instead of points, the polygon fills box, and anchor and rotate work like on a rect (it turns around the anchor point). A polygon needs exactly one of points and shape (error 1111).

{ "id": "star", "type": "polygon", "shape": { "type": "star" }, "box": { "x": 340, "y": 160, "w": 80, "h": 80 }, "fill": "#FFD166" }
typeShapecountinner
starA star, point uppoints, default 5inner radius as a fraction of the outer, default 0.5
polygonA regular polygon, corner upsides, default 6
trianglePoint up
diamond
arrowA block arrow pointing right (turn it with rotate)shaft thickness, default 0.45
crossA plus signarm thickness, default 0.34
chevronPointing rightthickness, default 0.4

count and inner are numbers or expressions.

In the editor you drag polygon points on the canvas; a shape polygon gets box handles instead, and the inspector switches between points and a shape. See Builder: Canvas.

Gradient

gradient fills the layer with blended colors instead of fill, as on a rect.

↑↓ to moveEnter to openEsc to close