Skip to content
On this page

Polygons

Polygons take a number of points and create a closed shape.

Code
vue
<script setup lang="ts">
import { Mafs, Cartesian, Polygon, MovablePoint, useMovablePoint, Theme, vec } from 'mafs-vue'

const a:vec.Vector2 = [2, 0]
const b:vec.Vector2 = [-2, 0]
const c = useMovablePoint([0, 2])
</script>

<template>
    <Mafs :height="300">
        <Cartesian />
        <Polygon :points="[[c.point[0], -c.point[1]], a, b]" :filled="{ strokeStyle: 'dashed' }" />
        <Polygon :points="[c.point, a, b]" :filled="{ color: Theme.blue }" />
        <MovablePoint :ctx="c" />
    </Mafs>
</template>

Props

<Polygon ... />

NameDescriptionDefault
points
vector2[]
filled
FilledProps
Code
vue
<script setup lang="ts">
import { Mafs, Cartesian, Polyline, MovablePoint, useMovablePoint, Theme, vec } from 'mafs-vue'

const a: vec.Vector2 = [-2, -2]
const b = useMovablePoint([-1, 1])
const c = useMovablePoint([1, -1])
const d: vec.Vector2 = [2, 2]
</script>

<template>
    <Mafs :height="300">
        <Cartesian />
        <Polyline :points="[a, b.point, c.point, d]" :filled="{ color: Theme.blue }" />
        <MovablePoint :ctx="b" />
        <MovablePoint :ctx="c" />
    </Mafs>
</template>

Props

<Polyline .../>

NameDescriptionDefault
points
vector2[]
filled
FilledProps

FilledProps

filled—can be configured with the following options:

  • color: string default: var(--mafs-fg).
  • weight: number default: 2.
  • fillOpacity: number default: 0.15.
  • strokeOpacity: number default: 1.
  • strokeStyle: "solid" | "dashed" default: "solid".