3.0.0 • Published 4 years ago

multipolar v3.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

about

Parametric solutions for common polar equations worth drawing with, superformula included.

setup

Download from the npm registry:

# Add to package.json
npm install multipolar

usage

Expect pure functions as named exports returning arrays of points represented as { x, y } object literals. For example,

import { poly } from "multipolar"

const canvas = document.createElement("canvas")
const target = canvas.getContext("2d")
const center = { x: canvas.width * 0.5, y: canvas.height * 0.5 }

// Draw an evil pentagram
const points = poly(center.y, 5)

target.translate(center.x + 0.5, center.y + 0.5)
target.rotate(Math.PI * 0.5)
target.beginPath()

points.forEach((p, i) => {
  const s = (i + 3) % points.length
  const n = points[s]

  target.moveTo(p.x, p.y)
  target.lineTo(n.x, n.y)
})

target.stroke()

document.body.appendChild(canvas)

see also

1.0.2

4 years ago

3.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago