-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(): skewing controls #8380
fix(): skewing controls #8380
Conversation
let's address the
|
Great context.
Can't guess what these mean.
Could you add visuals? |
i need to install inkscape and record but i think is something to compare with and better than nothing. I think that Inkscape normalize the bounding box each transformation to reduce issues and complexity, that is what i meant with use qrDecompose more. It flattens the transformation to remove one skew factor. a binary search in future skew values that will make the mouse and the control conincident |
Inkscape normalize the bounding box on rotation and not in skew. That would probably remove weird jumps entirely |
progress progress(): position major progress fix(): flip cleanup no multiply good state! fix(): successive skewing cleaup
I have done a major refactoring that will probably enable not using Please check the interaction for accuracy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed tests
src/shapes/object.class.ts
Outdated
this.set('scaleX', scaleX); | ||
this.set('scaleY', scaleY); | ||
this.angle = angle; | ||
this.skewX = skewX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a case that you warned from
I tried calling set
instead of manual assignment but since polys run a side effect this breaks.
I can set initialized=false
so it won't run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intialized false has to go away, do not make it more necessary that it is now.
To me that is dangerous since I can't use it everywhere and for everything so I keep my guards up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
READY after comments and extensive skewing with:
- scaling
- flipping
- rotating
- initial skewing
- double skewing
- vpt
- successive skewing in all the above
seems 91c5d72 fixed #8380 (comment) (files were displayed in B units, not KB) |
Ok so i tried it, and the flip behaviour is changed. You can compare a single flip target with master to see that some direction changes when skewing and it just feels innatural. |
So funny |
If this continues please share a screen cast |
|
||
const finalHandler = wrapWithFireEvent( | ||
'skewing', | ||
wrapWithFixedAnchor((eventData, transform, x, y) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this affects perf?
Going to retry now, i was literally adding -1 and 1 randomly around with the flipX !== flipY logic |
still remaining one edge case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is fixed now
But I have seen another related bug that exists on master as well
I think it happens only when skewing Y and when skewY * skewX < 0
, then target is kind of flipped
In the video I am pulling the mr corner
Parcel.Sandbox.-.Google.Chrome.2022-10-28.11-15-18.mp4
yes now it behaves more consistently. Good pr! |
Co-authored-by: @luizzappa
Motivation
Skewing is buggy in some cases .
#8344 has introduced changes that break the skewing controls.
Description
Existing logic is brilliant! It used the distance between the pointer and the origin point to determine the size of the target's axis (twice the diff). Then it extracted skewing as follows:
Apparently the problem lied in the calculation of width (x) when calculating the skewed height (y) when skewing y
Problems with the previous impl:
qrDecompose
seems to mess everything up (I think)fixed in https://github.com/fabricjs/fabric.js/compare/fix-skewing-controls2(thanks to @luizzappa pointing out that skewX depends on skewY but not the other way round), still buggy inside groupI can't think of a decent way around this unless we don't calculate the projections while skewing.This led me to seek a solution that compares against the last skewing state.I have tried to come up with a different approach, relying purely on linear algebra.
If fabric move away from decomposition then we can look into that (see Gist).
This PR is intended eventually to work only with matrices, but as long as fabric relays on decomposition skewY will not work.
I think if we can live without decomposing we should (canvas API doesn't decompose), but that's a tale for another time.
Another thought I had is that in the case of skewing Y we know the value of skewX so that might be enough to alter the decomposition to return a skewY value, @asturur ?
Changes
Gist - IGNORED, here for future use only
Calculating Shearing
We are looking for the shearing values of the transform matrix defined by the pointer offset.
Calculating the new transform
The following solves for
skewX
,same process is done for(need to account for cross axis skewing)skewY
This logic is not used in the PR but is here in case we decide to set the transform matrix directly instead of decomposed values.
Doing the same for
skewY
results in:WRONG - we must figure out how to extract scaleX/skewX
I have managed to get skewX to work with both approaches. SkewY however...
TO DO
In Action