Skip to content

liuyuchenzh/canvas-node

Repository files navigation

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

About

Use object to represent simple canvas shape

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published