![](https://secure.gravatar.com/avatar/eb3fe37da4a199eb4e3b479d8a57f808.jpg?s=120&d=mm&r=g)
On Tue, 2004-06-22 at 15:11, John Cliff wrote:
Have commited the stuff I was working on to
give control knots for manipulating pattern fills. Knots are currently provided for translation, rotation and scaling. Theres a circular node at the pattern 0,0 with 2 diamonds, one to the right, and on below (in the pattern co-ord system). To move the pattern, drag the circle, to rotate, drag the diamond to the right, to scale the one below. I'm putting thought into how best to do skew and non uniform scale, however need to discuss that with people, both from UI and maths point of views, so dont intend trying to get those done for 0.39.
I think a better approach, given that arrangement of knots, is something like this (imagine X is your diamond shape):
^ V (skew)
O------X <-> (scale) | | | X <-> (skew)
^ V (scale)
So, from the initial position (i.e. no transform) dragging the:
center knot: any direction = translation
right knot: up or down = skew vertically right or left = scale horizontally
bottom knot: right or left = skew horizontally up or down = scale vertically
IOW, motion parallel to the line between the center knot and the knot being dragged will cause scaling, and motion perpendicular to that line will cause skewing.
Holding down shift will limit it to only scaling or skewing at a time, depending on whether the motion is closer to parallel or perpendicular.
Holding down control while dragging the right or bottom knots will cause uniform scaling and rotation instead of a one-axis skew.
[ rotation = uniform skew on both axes ]
[ Variation on the idea:
Uniform scaling/rotation would be the default, and only the center and the bottom knot are shown. Holding down control shows the third knot and permits non-uniform scaling/skewing. I think I like that better..]
Anway, doing it this way also means a very direct relationship to the math: taking the translation and default knot distance out of the picture first, you are left with a center knot at 0,0, the right knot at 1,0, and the bottom knot at 0,1 (or 0,-1, depending on how you've set up your coordinate system).
Applying the non-translation portion of your matrix to those two knot coordinates will let you break it down into separate horizontal and vertical skews+scales.
For each axis, scale is the distance of its transformed knot from the center, and skew is the angle between a line drawn from the center to the knot's original position and one drawn from the center to its transformed one.
Nathan or someone can help you with the math to reverse the process and compute the "delta" transform between two knot positions if you can't figure it out (I'm tired and have a headache).
-mental