Chapter 7: May cause seizures

by Stéphane Cabaret

JavaScript

var paper = Raphael(0, 0, 500, 500);

var square = paper.rect(20, 20, 30, 30).attr({ 'stroke-width': 0, fill: "red" });

console.log(Raphael.easing_formulas);

Raphael.easing_formulas.swing = function(n) {
    return n + Math.sin(n * Math.PI * 2) / 2;  
};

Raphael.easing_formulas.random = function(n) {
    return n + 0.2 * Math.random() - 0.1;  
};

square.animate({ transform: "t200,200" }, 2000, "swing");