Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to rotate a vector rectangle in faux 3d?
    primarykey
    data
    text
    <p>I am using paper.js to create a vector rectangle shape that I'd like to be able to rotate in faux 3d by moving the path segments based on the mouse position.</p> <p>Here's my rectangle:</p> <pre><code>var center = view.center; var rectangle = new Rectangle(new Point(0, 0), new Point(300, 200)); path = new Path.Rectangle(rectangle); path.position = center; </code></pre> <p>This is the event function that I'm using to move the points around:</p> <pre><code>function onMouseMove(event) { mousePos = event.point - center; for (var i=0,sl=path.segments.length;i&lt;sl;i++) { var segment = path.segments[i]; if (i==0) { segment.point.x = orig[i].x+mousePos.x; segment.point.y = orig[i].y+mousePos.y; } else if (i==1) { segment.point.x = orig[i].x+mousePos.x; segment.point.y = orig[i].y+mousePos.y; } else if (i==2) { segment.point.x = orig[i].x-mousePos.x; segment.point.y = orig[i].y-mousePos.y; } else if (i==3) { segment.point.x = orig[i].x-mousePos.x; segment.point.y = orig[i].y-mousePos.y; } } } </code></pre> <p><code>orig</code> is a simple object with <code>x</code> and <code>y</code> properties that hold the original points for each segment(<code>0,0,300,200</code>).</p> <p>Ideally, the points would move so that the point closest to the mouse would come forward with perspective.</p> <p>What is the best way to accomplish this? The above attempt is not ideal since it stretches the shape horizontally.</p> <p><a href="http://jsfiddle.net/ceT7g/2/" rel="nofollow">jsFiddle Example</a></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.
    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