0.5.0 • Published 9 months ago

@litecanvas/plugin-more-shapes v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

More Shapes plugin for litecanvas

Plugin to draw shapes like ellipse and polygons in litecanvas games.

Install

NPM: npm i @litecanvas/plugin-more-shapes

CDN: https://unpkg.com/@litecanvas/plugin-more-shapes/dist/dist.js

Usage

See a demo on playground.

vertices(points: number[][])

Draw lines connecting vertices.

import litecanvas from "litecanvas"
import pluginMoreShapes from "@litecanvas/plugin-more-shapes"

// example: draw a triangle
function draw() {
  cls(0)

  vertices([
    // X Y points
    [0, 128],
    [128, 128],
    [64, 0],
  ])

  // you should choose fill or/and stroke that vertices
  stroke(4)
  // or/and
  // fill(5)
}

oval(x, y, rx, ry, color)

Draw a ellipse outline.

import litecanvas from "litecanvas"
import pluginMoreShapes from "@litecanvas/plugin-more-shapes"

function draw() {
  cls(0)
  oval(100, 100, 32, 64, 4)
}

ovalfill(x, y, rx, ry, color)

Draw a color-filled ellipse.

rpol(x, y, sides, radius, color)

Draw a regular polygon outline.

import litecanvas from "litecanvas"
import pluginMoreShapes from "@litecanvas/plugin-more-shapes"

function draw() {
  cls(0)
  rpol(100, 100, 5, 64, 4)
}

rpolfill(x, y, sides, radius, color)

Draw a color-filled regular polygon.

star(x, y, tips, radius, color)

Draw a star outline.

import litecanvas from "litecanvas"
import pluginMoreShapes from "@litecanvas/plugin-more-shapes"

function draw() {
  cls(0)
  star(100, 100, 8, 64, 5)
}

starfill(x, y, tips, radius, color)

Draw a color-filled star.

0.5.0

9 months ago

0.4.3

12 months ago

0.4.2

12 months ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.2

1 year ago

0.3.3

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago