flip or mirror transform

1,608 views
Skip to first unread message

Sam Matthews

unread,
Apr 26, 2014, 4:30:47 PM4/26/14
to pap...@googlegroups.com
Hi, 
I'm new to Paper.js .. and am experimenting in doing some animation with loaded images.  Is there any simple way to perform a horizontal and/or vertical flip on an object.  I've had success with scale and rotate, but can't seem to figure out how to 'flip' an object.  I've been thinking there is a way the Matrix.. but I can't get my head around it.  Any help much appreciated...

Sam

Jonathan Puckey

unread,
Apr 26, 2014, 4:31:53 PM4/26/14
to pap...@googlegroups.com
how about:
flip horizontal: item.scale(-1, 1)
flip vertical: item.scale(1, -1)

--
You received this message because you are subscribed to the Google Groups "Paper.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam Matthews

unread,
Apr 27, 2014, 6:46:10 PM4/27/14
to pap...@googlegroups.com
Thanks so much… I knew there was a way… I just couldn’t remember how to do it.



You received this message because you are subscribed to a topic in the Google Groups "Paper.js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/paperjs/YIpLMZqhWDs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to paperjs+u...@googlegroups.com.

julien....@gmail.com

unread,
Sep 24, 2014, 3:23:46 AM9/24/14
to pap...@googlegroups.com
I was looking for the same kind of function and found this post.

for anyone who cares, I have extended Path() so it's easier to chain and use a mirror function:

Path.prototype.mirror = function(orientation) {
   
var axis = {
           
'horizontal': {
               
'x': -1,
               
'y': 1
           
},
           
'vertical': {
               
'x': 1,
               
'y': -1
           
}
       
}
   
return this.scale(axis[orientation].x, axis[orientation].y);
};

To be used like:

myPath.mirror('horizontal');

Hope that helps
Reply all
Reply to author
Forward
0 new messages