TypstDocumentation

polygonElement
Question mark

A closed polygon.

The polygon is defined by its corner points and is closed automatically.

Example

#polygon(
  fill: blue.lighten(80%),
  stroke: blue,
  (20%, 0pt),
  (60%, 0pt),
  (80%, 2cm),
  (0%,  2cm),
)
Preview

Parameters
Question mark

fill
none or color or gradient or pattern
Settable
Question mark

How to fill the polygon.

When setting a fill, the default stroke disappears. To create a rectangle with both fill and stroke, you have to configure both.

Currently all polygons are filled according to the non-zero winding rule.

Default: none

stroke
none or auto or length or color or gradient or stroke or pattern or dictionary
Settable
Question mark

How to stroke the polygon. This can be:

Can be set to none to disable the stroke or to auto for a stroke of 1pt black if and if only if no fill is given.

Default: auto

vertices
array
RequiredPositional
Question mark
Variadic
Question mark

The vertices of the polygon. Each point is specified as an array of two relative lengths.

Definitions
Question mark

regular

A regular polygon, defined by its size and number of vertices.

#polygon.regular(
  fill: blue.lighten(80%),
  stroke: blue,
  size: 30pt,
  vertices: 3,
)
Preview

fill
none or color or gradient or pattern

How to fill the polygon. See the general polygon's documentation for more details.

stroke
none or auto or length or color or gradient or stroke or pattern or dictionary

How to stroke the polygon. See the general polygon's documentation for more details.

size

The diameter of the circumcircle of the regular polygon.

Default: 1em

vertices

The number of vertices in the polygon.

Default: 3