-
-
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
patch(matrix): expose calcPlaneRotation
#9419
Conversation
Build Stats
|
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.
small and concise
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.
getTotalAngle has the benefit of returning a shortcut of the plane rotation for simple objects that have no nested situations.
So please keep using it where it was, since you removed the overhead of qrDecompose from it. The conversion from radians to degree is a multiplication and is not worth loosing the optimization for the common use case.
src/controls/controlRendering.ts
Outdated
const angle = fabricObject.getTotalAngle(); | ||
ctx.rotate(degreesToRadians(angle)); | ||
// rotation is relative to canvas plane | ||
ctx.rotate(calcPlaneRotation(fabricObject.calcTransformMatrix())); |
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.
So please keep using it where it was, since you removed the overhead of qrDecompose from it. The conversion from radians to degree is a multiplication and is not worth loosing the optimization for the common use case.
are you talking about this change??
I don't get your reason, what do you mean?
Why change to an angle and back to rad? It is purly redudant
yes i want to keep getTotalAngle in use because it avoids using the calcTransformMatrix when there is no need for it. It may be redundant to convert an angle to a degree, but is way less than creating the matrix from scratch when there is no need to it because we just need the angle. By putting calcPlaneRotation in place where a simple angle would be ok you are wasting more than you are gaining. We added getTotalAngle because we had to take in account the new edge case of nested objects, but that is not the norm. That would have been just 'this.angle' before, and that is what it is in most of the cases. Your Motivation: Motivation 1:
^ this are facts and are correct, i can't really say nothing about. An additive change and some calculation change, fine. Motivation 2:
^ this is a belief to which i disagree with and so the path of not changing is the preferred one. That is not the direction we will go if we don't find a framework to collaborate in advance on changes. |
That is why I wrote I believe
I don't see a case where a matrix is not created, please enlighten me. I do not want to defend so enlighten me instead. |
is not esoteric performance issues. So all the time you are running findCornerQuadrant on an object that has no group, calling getTotalAngle will let us pick the best way to get angle for that situation. |
I actually forgot to expose this |
Motivation
I need to calc angles of planes/matrices in certain cases.
I prefer to avoid decomposition because in most cases I need the radian value and not the degree.
In addition the rest of the calculation is not needed and is wasteful in terms of perf.
Also I believe fabric can and should reduce its dependancy on decomposition for all the known and unknown reasons, some I discovered in #8767
This is a small step in that direction.
Description
Expose
calcPlaneRotation
and use it across fabric.There a number of usages I left in functions I dislike and that I have changed in several open PRs.
I do not want conflicts nor do I want to patch them because they need extensive work.
Changes
Gist
In Action