Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:56:12+00:00 2026-06-13T22:56:12+00:00

How can I animate a vector path being drawn with Raphael JS? I have

  • 0

How can I animate a vector path being drawn with Raphael JS?

I have a set of coordinates that I would like to connect using Raphael JS.

On a grid, the coordinates are (x,y sets). I would like to start from one end and “connect the dots” as the user watches. The end product would look something like this:

Picture 9.png http://img213.imageshack.us/img213/8013/picture9my.png

Ideally, I would like to be able to make the paths curved so they would look more like this (coordinates added for reference):

Picture 10.png http://img534.imageshack.us/img534/1789/picture10fc.png

The coordinates are:

26,-6
14,-12
5,-20
11,-28
14,-37
5,-40

I’ve been searching Google and I have read through this question How to draw a vector path progressively? (Raphael.js) but I am trying to use Raphael.js specifically and the example on that page for Raphael.js does not seem to work nor does it talk about using multiple coordinate points for inputs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:56:13+00:00Added an answer on June 13, 2026 at 10:56 pm

    Progressive Paths

    Drawing a path progressively is easy to do. I dislike the second-most-accepted answer on this question because it recreates a path at every step, clearing the paper in between. Here’s the utility function I’ve used time and time again:

    function drawpath( canvas, pathstr, duration, attr, callback )
    {
        var guide_path = canvas.path( pathstr ).attr( { stroke: "none", fill: "none" } );
        var path = canvas.path( guide_path.getSubpath( 0, 1 ) ).attr( attr );
        var total_length = guide_path.getTotalLength( guide_path );
        var last_point = guide_path.getPointAtLength( 0 );
        var start_time = new Date().getTime();
        var interval_length = 50;
        var result = path;        
    
        var interval_id = setInterval( function()
        {
            var elapsed_time = new Date().getTime() - start_time;
            var this_length = elapsed_time / duration * total_length;
            var subpathstr = guide_path.getSubpath( 0, this_length );            
            attr.path = subpathstr;
    
            path.animate( attr, interval_length );
            if ( elapsed_time >= duration )
            {
                clearInterval( interval_id );
                if ( callback != undefined ) callback();
                    guide_path.remove();
            }                                       
        }, interval_length );  
        return result;
    }
    

    You can see it in action on my site.

    This alone would make animating the progressive path construction of your points in a linear fashion absolutely simple. You’d simply compile your path…

    var sequence_path = ["M26,-6", "L14,-12", "L5,-20", "L11,-28", "L14,-37", "L5,-40"];
    

    And then pass it to whatever path animation function you’ve set up. In my case,

    drawpath( paper, 
              sequence_path, 
              3500, 
              { stroke: 'black', 'stroke-width': 2, 'stroke-opacity': 1, fill: 'none', 'fill-opacity': 0 }, 
              function()
              {
                  alert("All done");    // trigger whatever you want here
              } );
    

    Curve Interpolation

    Raphael 2.0’s Catmull Rom feature makes curving gracefully between your points extremely straightforward (thanks to Erik Dahlström for pointing this out). All you need to do is construct a path using the ‘R’ command to move between points, and Raphael will do the rest.

    function generateInterpolatedPath( points )
    {
        var path_sequence = [];
        path_sequence.push( "M", points[0].x, points[0].y );
        path_sequence.push( "R" );
        for ( var i = 1; i < points.length; i++ )
        {
            path_sequence.push( points[i].x, points[i].y );
        }
        return path_sequence;
    }
    

    You can see all the pieces working together here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have certain set of predefined css classes, using which i can animate a
I am searching for an Asp.net control like this one ,that can animate and
If i have my animations defined in xml then i can animate between activities
this is my script, I'm using a toggle so I can animate a sliding
My Question : How can i trigger webbrowser events like navigating/navigated so that i
I read that SVG animatable properties like transform can be animated by CSS transitions.
Is there an application that can animate graph algorithms? I find it much easier
How can I animate some object like ListboxItem when I click to start SuckEffect
I'm using jQuery and trying to animate a <select> box where the width would
Is there any way i can animate a div using percentages with jquery? I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.