Stroke Width Change When Applying Affine Transform Directly on Path Object

151 views
Skip to first unread message

ly20...@gmail.com

unread,
Jun 7, 2017, 8:41:19 PM6/7/17
to Paper.js
I wanted to keep segments in a path managed by my own coordinate system and set the paperjs transformation directly based on a view change. -- the path itself does not change, but the view changes.

I used the following code snippet.

var path = new paper.Path();
path.applyMatrix = false;
// :
// :
// : calculating transform m based on view change
// : m = [a, b, c, d, tx, ty] 
path.matrix.set(m[0], m[1], m[2], m[3], m[4], m[5]);

while the path gets draw properly with respect to the coordinates, the stroke width changes instead of staying constant. That is, when I zoom in, the stroke becomes thicker, and when I zoom out the stroke becomes thinner. I would like it to stay constant, is there a suggested way to do this instead of changing the stroke width to compensate it?

Thank you!

Jürg Lehni

unread,
Jun 8, 2017, 6:32:16 AM6/8/17
to pap...@googlegroups.com
You can try turning off stroke-scaling:

    path.strokeScaling = false;

Also, please note that this should too in v0.10.3:

    path.matrix.set(m);

--
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.

ly20...@gmail.com

unread,
Jun 8, 2017, 9:14:21 AM6/8/17
to Paper.js
Thank you Jürg for the prompt reply!

My fault for not looking at the API doc carefully...it was there now that I read it again.

Really enjoy using paperjs and thank you and Johnathan for the great work!

ly20...@gmail.com

unread,
Jun 8, 2017, 9:39:39 AM6/8/17
to Paper.js
Also Jürg can you advise on how to change the styling of the handle? In addition to changing the size using

paper.settings.handleSize

I'd also like to change its shape to a circle and also change its fill style depending on whether a handle is hit (say, from non-filled to filled). Or for even more flexibility is it possible to supply my own shape using a closed path from paperjs or a drawing routine when a position is supplied (if I can inject my own drawHandle and hit test routines)?

Than you!
 
On Thursday, June 8, 2017 at 3:32:16 AM UTC-7, Jürg Lehni wrote:

Jürg Lehni

unread,
Jun 9, 2017, 1:56:07 AM6/9/17
to pap...@googlegroups.com
Those things aren’t possible right now, but there’s an issue for it. Happy to accept a PR:

Reply all
Reply to author
Forward
0 new messages