Skip to content

IAIAE/canvas-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usage

var Path = require('canvas-path')


var path = new Path({
    points: [
        [[100,200], [200,123]],
        [[200,123], [300,200]]
    ],
    duration: 4000,
    easing: 'easeInOutCubic'
})

function tick(t){
    var point = path.tick(t);
    // drawPoint(point[0], point[1])  // point[0]:x, point[1]:y
    if(!path.isEnd()) requestAnimationFrames(tick)
}
requestAnimationFrames(tick)

api

path.on('start', function(point){
    // do some thing
})
.on('end', function(point){
    // do some thing
})
.on('tick', function(point, timestamp){
    // depreciate cause it's takes time.
})

demo

see the test.html in test folder.

performance

new Path() don't hold any timer in it. so, if you donot use it, it will released by the GC, that's makes it easy-to-use, and plain to handle.

chage note

  • v1.0.1 LinePath is available
  • v1.1.0 QuadraticPath is available
  • v1.1.1 BezPath is available
  • v2.0.0 change api, only use Path.of to create path. deduce the complexity to use this library.

todo

maybe modulize next time.

About

a Path class that generate path for canvas render.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published