Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>UPDATED to apologize for previous idiocy:</p> <p>I typically use a utility function like the following to draw arbitrary paths over a given duration of time:</p> <pre><code>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 = 25; 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 &gt;= duration ) { clearInterval( interval_id ); if ( callback != undefined ) callback(); } }, interval_length ); return result; } </code></pre> <p>In this case, you'd simply call</p> <pre><code>var rectPath = drawpath( paper, "M10 10 L510 10 L510 14 L10 14 z", 4000, function() { // want to apply some other attributes to the finished rectangular path? Here's where you'd do it. } ); </code></pre> <p>This has the advantage of working with all sorts of complicated shapes, include textual paths if you're using <code>print</code>. That means you can accomplish moderately more impressive drawing effects, like <a href="http://voidblossom.com/tests/pathTransform.php" rel="nofollow">this</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload