Note that there are some explanatory texts on larger screens.

plurals
  1. POScroll along path Paper.js
    primarykey
    data
    text
    <p>Basically I want to scroll a object along path. I've seen several threads looking for similar solution not using paper.js but i was wondering if this possible with paper.js. Or can someone give me a working jsfiddle of object follow svg curve because I couldn't get any thing to work. I ultimately want to have a chain of divs follow the path. </p> <pre><code>// vars var point1 = [0, 100]; var point2 = [120, 100]; var point3 = [120, 150]; // draw the line var path = new Path(); path.add(new Point(point1), new Point(point2), new Point(point3)); path.strokeColor = "#FFF"; path.closed = true; // draw the circle var circle = new Path.Circle(0,100,4); circle.strokeColor = "#FFF"; // target to move to var target = point2; // how many frame does it take to reach a target var steps = 200; // defined vars for onFrame var dX = 0; var dY = 0; // position circle on path circle.position.x = target[0]; circle.position.y = target[1]; function onFrame(event) { //check if cricle reached its target if (Math.round(circle.position.x) == target[0] &amp;&amp; Math.round(circle.position.y) == target[1]) { switch(target) { case point1: target = point2; break; case point2: target = point3; break; case point3: target = point1; break; } // calculate the dX and dY dX = (target[0] - circle.position.x)/steps; dY = (target[1] - circle.position.y)/steps; } // do the movement //circle.position.x += dX; //circle.position.y += dY; } </code></pre> <p>Here is the jsfiddle: <a href="http://jsfiddle.net/J9xgY/12/" rel="nofollow">http://jsfiddle.net/J9xgY/12/</a></p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    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. 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