Nascent Prototype Metaverse
    Have ideas to improve npm?Join in the discussion! »

    multipolar

    0.0.7 • Public • Published

    about

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

    setup

    Find the latest version on the npm registry:

    # Includes ES and CJS modules 
    npm install @thewhodidthis/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 = (+ 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

    Keywords

    Install

    npm i multipolar

    DownloadsWeekly Downloads

    11

    Version

    0.0.7

    License

    ISC

    Unpacked Size

    81.2 kB

    Total Files

    11

    Last publish

    Collaborators

    • avatar