Skip to content

Drawing Polygons

Draws a polygon for a set of vertices.

WARNING

A polygon requires at least three vertices. Otherwise, an error will be thrown.

Props

NameDescriptionTypeDefault
verticesThe vertices of the polygon.PossibleVector2[]none
colorThe stroke color of the polygon.string#000
line-widthThe stroke line width of the polygon.number1.25
fillThe fill color of the polygon.stringnone
dashedWhether the polygon should be drawn with a dashed stroke.booleanfalse
anglesWhether to draw the interior angles of the polygon.booleanfalse
angle-radiusThe radius of the interior angles.number1
angle-dashedWhether the interior angles should be drawn with a dashed stroke.booleanfalse

Examples

Triangle

Code
vue
<template>
  <Graph :units="false" :grid="false" :axis="false">
    <Polygon
      :vertices="[
        [-3, -2],
        [-3, 4],
        [4.5, -2],
      ]"
    />
  </Graph>
</template>

Regular Hexagon with Angles

Code
vue
<template>
  <Graph :units="false" :grid="false" :axis="false">
    <Polygon
      :vertices="[
        [-1, 0.732],
        [0, 2.464],
        [2, 2.464],
        [3, 0.732],
        [2, -1],
        [0, -1],
      ]"
      angles
      :angle-radius="0.7"
    />
  </Graph>
</template>