Skip to content

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

License

Notifications You must be signed in to change notification settings

litecanvas/plugin-more-shapes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published