Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Сценарий из raw.github.com/theshock/libcanvas/master/libcanvas-full-compiled.js был заблокирован из-за несоответствия типа MIME

helper = new App.Light(new Size( width, height ));
// =>
helper = new App.Light(new Size( width, height), { intersection: 'full' });
atom.declare( 'Star', App.Element, {
progress: 0,
opacity: 1,
configure: function () {
var screenRectangle = this.layer.ctx.rectangle;
this.animate = new atom.Animatable(this).animate;
this.from = screenRectangle.getRandomPoint();
this.shape = new Polygon(this.from.clone(), this.from.clone(), this.from.clone());
this.angle = -this.from.angleTo(screenRectangle.center);
this.sin = this.angle.sin();
this.cos = this.angle.cos();
this.progressSpeed = Math.random() + 0.5;
this.color = new atom.Color(128, 128, Number.random(128, 192)).toString();
setTimeout(this.fadeOut.bind(this), Number.random(1000, 8000));
},
fadeOut: function () {
this.animate({
time: 2000,
props: { opacity: 0 },
onComplete: this.destroy
});
},
onUpdate: function () {
var sin = this.sin, cos = this.cos, p = this.shape.points;
this.progress += this.progressSpeed;
p[1].x = p[0].x + this.progress * cos;
p[1].y = p[0].y - this.progress * sin;
p[2].x = p[1].x + 2 * sin;
p[2].y = p[1].y + 2 * cos;
this.redraw();
},
renderTo: function (ctx) {
ctx.save();
if (this.opacity < 1) ctx.set({ globalAlpha: this.opacity });
ctx.fill( this.shape, this.color );
ctx.restore();
}
});
new function () {
var helper = new App.Light(
new Size(document.width || 800, document.height || 800),
{ intersection: 'full', invoke: true }
);
for(i = 0; i < 200; i++) new Star(helper.layer);
atom.frame.add(function () {
new Star(helper.layer);
});
};

Гиперпространство на JavaScript