for (var i = total - 1; i > 1; i--) {
p0 = points[i];
p1 = points[i - 1];
p2 = points[i - 2];
context.beginPath();
context.strokeStyle = p0.color;
context.lineWidth = p0.size;
context.globalAlpha = i / total;
context.moveTo((p1.x + p0.x) / 2, (p1.y + p0.y) / 2);
context.quadraticCurveTo(p1.x, p1.y, (p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
context.stroke();
p0.spread();
}
points[0].spread();
points[total - 1].spread();
}
function draw() {
// Line movement
var dx = (mouseX - px) * SPEED_X,
dy = (mouseY - py) * SPEED_Y;
// Limit the amount of movement
if (dx < -spread) {
dx = -spread;
} else if (dx > spread) {
dx = spread;
}
if (dy < -spread) {
No comments:
Post a Comment