jcc2d
A canvas 2d renderer & An awesome animator
Show case
Introduction
main page
jcc2d
is a lightweight canvas2d-render engine and built-in an awesome animator with timeline manager. obviously, jcc2d
support event system by default.
jcc2d
built-in support bodymovin keyframes data, which use bodymovin add-on to exporting keyframes data
from after effect, and jcc2d
can parse the keyframes data
to jcc2d keyFrames animation, just like following:
const ani = new JC.ParserAnimation({
keyframes: data,
onUpdate() {},
onComplete() {
console.log(this.element);
},
});
const coin = new JC.Sprite({
texture: new JC.Texture('/path/coin.png'),
});
coin.keyFrames({
ks: data.layers[0],
fr: 30,
onUpdate() {},
onComplete() {
console.log(this.element);
},
});
view demo
Feature
jcc2d
Include Stage
Sprite
Graphics
Container
BlurFilter
TextFace
and so on.
Every display instance can easy start an animation and attach a timeline, like following:
const ball = new JC.Sprite({
texture: new JC.Texture('/path/xx.png'),
});
const timeline = ball.animate({
from: {x: 100},
to: {x: 200},
ease: JC.Tween.Bounce.Out,
repeats: 10,
delay: 1000,
wait: 1000,
infinite: true,
alternate: true,
duration: 1000,
onUpdate: function(state,rate){},
onComplete: function(){ console.log('end'); }
});
timeline.pause();
timeline.restart();
timeline.stop();
timeline.cancle();
timeline.timeScale = 0.5;
Display animation property
type | property |
---|
display instance scale value | scale scaleX scaleY |
display instance origin | originX originY |
display instance pivot | pivotX pivotY |
display instance skew value | skewX skewY |
display instance rotation with CCW | rotation |
display instance coordinate axis position | x y |
display instance opacity alpha | alpha |
Quick Start
jcc2d
was so easy to use, you just need new
a Stage
instance and appoint a canvas
dom, then you can add every display object into stage
.
const stage = new JC.Stage({
dom: 'canvas-stage',
resolution: 1,
});
const coin = new JC.Sprite({
texture: new JC.Texture('/path/coin.png'),
});
stage.adds(coin);
stage.startEngine();
jcc2d
built-in support timeline
animation , you can start multiple animation. let's use coin
to show.
coin.animate({
from: { x: 100, rotation: 0 },
to: { x: 300, rotation: 360 },
...
});
coin.motion({
path: new JC.BezierCurve([...]),
...
});
coin.runners({
runners: [
{from: {}, to: {}, ease: JC.Tween.Back.In, ...},
{path: new JC.BezierCurve([...]), ease: JC.Tween.Ease.Bezier(0, 0, 1, 1), ...},
{to: {}, ease: JC.Tween.Back.Out, ...},
],
...
});
would like to know more information please look in documentation, or quick start a living edit in web runing man.
Documentation
jcc2d
source code was used ES6 Modules
and build to UMD
bundle by rollup
. so jcc2d
can support tree-shaking
seamless.
import * as JC from 'jcc2d';
import { Stage, Sprite, Graphics } from 'jcc2d';
and if you just want use UMD
bundle, you can use require
method
const JC = require('jcc2d');
const JC = require('jcc2d/build/jcc2d.light.js');
documentation
Examples
examples
Changelog
changelog
License
MIT