Raphael 2.0 Catmull Rom Splines

Raphael 2.0 has support for Catmull Rom Splines. Very nice for easily drawing smooth paths:

…and here is the main part of the code:

 
 var p = new Raphael(0, 0, "100%", "100%");
 
       // catmull rom
       p.path("M 10 100 \
               R 30 50 \
               50 90 \
               70 20 \
               90 100 \
               110 90 \
               130 100").attr("stroke","white");
 
       // closed catmull rom
       p.path("M 200 20 \
               R 300 20 \
               300 120 200 120z").attr("stroke","white");

The “\” is used for javascript multiline strings – good for readability. The closed path has a “z” at the end to connect the last point to the first point.



 
 
 

One Response to “Raphael 2.0 Catmull Rom Splines”

  1. Abilash
    21. March 2013 um 22:33

    Thanks a lot,,,that helped me alot

Leave a Reply

Spam protection by WP Captcha-Free