canvas-node

Use oject to represent canvas drawings

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
canvas-node
0130.3.235 years ago5 years agoMinified + gzip package size for canvas-node in KB

Readme

Intro

Try to use object to represent canvas drawing.
Still under development

Usage

A basic one would be:
import CanvasNode from 'canvas-node'

const canvas = document.getElementById('canvas')
CanvasNode.init({canvas})
const vertexes = [0, 0, 50, 50]
const path = new Path2D()
path.rect(...vertexes)
const box = CanvasNode.drawBox({
    rawVertexes: vertexes,
    name: 'box',
    text: 'box',
    path,
    style: '#58a',
    strokeStyle: '#fff',
    pos: {x: 50, y: 50}
})

setTimeout(() => {
  box.moveTo({x: 100, y: 100})
}, 1000)

API

API documents can be found here

License

MIT
Copyright (c) 2017-present, Yuchen Liu