@litecanvas/plugin-more-shapes
v0.5.0
Published
Plugin to draw shapes like ellipse, stars and other polygons in litecanvas games
Downloads
9
Maintainers
Readme
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.