Skip to content
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

chore/fix(v6): prerequisites for Group #7728

Merged
merged 10 commits into from Feb 24, 2022
Merged

chore/fix(v6): prerequisites for Group #7728

merged 10 commits into from Feb 24, 2022

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Feb 21, 2022

same as #7710

BREAKING _getTransformedDimensions, now accepts an options object.
FIX: calcOCoords

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.26 |    76.65 |    86.4 |   82.99 |                                               
 fabric.js |   83.26 |    76.65 |    86.4 |   82.99 | ...,29773,29898,29978-30043,30166,30265,30482 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.27 |    76.68 |    86.4 |      83 |                                               
 fabric.js |   83.27 |    76.68 |    86.4 |      83 | ...,29773,29898,29978-30043,30166,30265,30482 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.27 |    76.68 |    86.4 |   82.99 |                                               
 fabric.js |   83.27 |    76.68 |    86.4 |   82.99 | ...,29769,29894,29974-30039,30162,30261,30478 
-----------|---------|----------|---------|---------|-----------------------------------------------

@ShaMan123 ShaMan123 changed the title chore(): use point - minor chore(): prerequisites for Group Feb 21, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.24 |    76.59 |   86.34 |   82.97 |                                               
 fabric.js |   83.24 |    76.59 |   86.34 |   82.97 | ...,29768,29893,29973-30038,30161,30260,30477 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.18 |    76.56 |   86.34 |   82.91 |                                               
 fabric.js |   83.18 |    76.56 |   86.34 |   82.91 | ...,29754,29879,29959-30024,30147,30246,30463 
-----------|---------|----------|---------|---------|-----------------------------------------------

@ShaMan123 ShaMan123 changed the title chore(): prerequisites for Group chore/fix(): prerequisites for Group Feb 21, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.17 |    76.52 |   86.34 |    82.9 |                                               
 fabric.js |   83.17 |    76.52 |   86.34 |    82.9 | ...,29754,29879,29959-30024,30147,30246,30463 
-----------|---------|----------|---------|---------|-----------------------------------------------

@ShaMan123 ShaMan123 changed the title chore/fix(): prerequisites for Group chore/fix(v6): prerequisites for Group Feb 21, 2022
@asturur
Copy link
Member

asturur commented Feb 22, 2022

This change in theory breaks the control api, because is passing to the conrol position handler a different matrix depending if it is in a group or not.
I don't think that is a real issue since controls in group nowadays do not really work.

I think those changes are fine, but i want to understand why we are adding scaleX and scaleY to getTransformedDimensions.
I would be eventually more happy to remove any option from that and move the special calculations to a util.

also getTotalAngle needs a double check for edge cases.

Let me think about it.

The very important part of this PR is the matrix shuffling away from rendering and put inside calcOcoords, and that seems good to me.

@ShaMan123
Copy link
Contributor Author

It actually fixes the control api, so yes, that's breaking :).

@github-actions
Copy link
Contributor

github-actions bot commented Feb 22, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.18 |    76.56 |   86.34 |   82.91 |                                               
 fabric.js |   83.18 |    76.56 |   86.34 |   82.91 | ...,29754,29879,29959-30024,30147,30246,30463 
-----------|---------|----------|---------|---------|-----------------------------------------------

@asturur
Copy link
Member

asturur commented Feb 22, 2022

What is fixing that in the api?

@ShaMan123
Copy link
Contributor Author

I mean that the control api was receiving bad data, wrong position of controls.
Now it is correct.

@asturur
Copy link
Member

asturur commented Feb 22, 2022

i would expect this PR to fix this rendering here:
image

from the visual test: controlboxes with skewY, green is wrong and needs fix

@asturur
Copy link
Member

asturur commented Feb 22, 2022

Or at least we should have a unit test that changes output before and after the change.

Or someone could come in 6 months, put the matrices as they were before, thinking that are better in another position and we don't have anything that catches the regression.

If no output is changing, fine, we are just making the code more straight and more generic but we are not breaking any behaviour of fix a bug.

@ShaMan123
Copy link
Contributor Author

If no output is changing, fine, we are just making the code more straight and more generic but we are not breaking any behaviour of fix a bug.

I didn't understand,
Did the visual test work before the change?
Are these objects inside a group?

@ShaMan123
Copy link
Contributor Author

How do I run this test? Can you try merging this on top of v6! and viewing the result?

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Feb 22, 2022

The problem with oCoords is that the calculation doesn't take into account skewing.
In addition the bbox of the border is calculated in a different way and I'm pretty sure oCoords doesn't comply.
I don't understand what goes where.

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Feb 22, 2022

And I remember we said that the rendering of controls should be looked into deeply

@ShaMan123
Copy link
Contributor Author

And even more we talked about dropping double coord system...
I don't really understand why the calculations of aCoords and oCoords are different (except from vpt)

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Feb 22, 2022

calcLineCoords is broken, now I see. I doesn't take into account the group
I am confused

@asturur
Copy link
Member

asturur commented Feb 22, 2022

What i m saying is just, why no tests are failing? If no tests fails either we miss a test that cover the case we are changing, or we are not changing oCoords.

To run that test you can do:

npm run test:visual:single test/visual/control_rendering.js

you can delete controls12.png from the golden folder and see if it gets created equal before and after building the lib.

@asturur
Copy link
Member

asturur commented Feb 22, 2022

And even more we talked about dropping double coord system... I don't really understand why the calculations of aCoords and oCoords are different (except from vpt)

They are different for historical reason.
oCoords existed initially. Zoom and pan did not exists.
A developer came after a bounty to implement pan/zoom.
oCoords got adapted to work on zoom and pan.
All the functions about intersection, contain and such were adapted for the zoom.
At that point to know where an object was on the canvas you had to update oCoords, and then remove the zoom/pan from it in order to get to absolute coordinates.
At that point aCoords ( absolute coords ) were added, to represent the 4 corners of the object, in design/canvas space, without the viewport.

The 4 corners of the object and controls mostly overlapped, until in fabric 4.0 the control api was introduced that freed the controls from static position.
But mouse targeting was still relying on oCoords to find the objects, so lineCoords were added, that are the oCoords version of the aCoords.

In theory lineCoords aren't necessary anymore and aCoords should do it after a proper refactor of the pointer interaction.

Calculations are today different because oCoords are completely custom and developer driven in theory and oCoords have to support padding, that is a pain, is the equivalent of the pain strokeUniform on controls. Because padding is independent from everything ( zoom, and transformations ) but needs to be added back and pre-transformed.

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Feb 22, 2022

Thanks for the explanation.
So I want to ask, are oCoords necessary as well? If they are good only for mouse interactions and we can transform (easily enough) the point into the canvas space is there any need for them? If they are needed shouldn't they be calculated from aCoords?
I have a more drastic idea/proposal. But a question first. Is this mess caused because of canvas transform?
I am beginning to think that canvas transform is a bad idea, too many cases to handle. However, implementing it using a Layer sounds relatively straight forward.
What I mean to say is maybe we should rethink the design of canvas. What should it do, what shouldn't it do and something else should and so on.
I believe the design spec got messed up because group was inadequate so it never came up as a solution (rather, a problem) and made everyone think of workarounds. Canvas transform seems to be such a workaround.
Think of a group/layer that goes in between the canvas and the objects as part of design. It will be in charge of transformations. The up side is that it leverages existing logic to so, object transform logic, and relieves canvas from that task. It's how it should be. SVG uses group like that, it's a building block. And I think we should do that as well.
Same goes for layout. I have opened issues for custom layout but the truth is that I can use the new group to achieve it.
I understand the need for incremental change. It's reasonable, maintainable, steady and healthy. But I don't want us to waste time on fixing hard, time-consuming logic instead of altering the design.

So for example we can decide, everything coming from outside of canvas doesn't enter until it is relative to canvas (and have 1 function that handles this transformation). This will imply positioning controls relative to canvas as well. I think it's the better way.

I can go on about design. I have a concept for canvas. So that devs can build there own flow for fabric with a custom stack of canvases and layers. Then rewriting top canvas will become unnecessary. The dev decides to push a canvas to stack and configures a task for it in the render cycle.

@ShaMan123
Copy link
Contributor Author

This change in theory breaks the control api, because is passing to the conrol position handler a different matrix depending if it is in a group or not.

It doesn't really affect the control because I simply applied the group transform early on in calcOCoords instead of in the event handler

@asturur
Copy link
Member

asturur commented Feb 24, 2022

oCoords are probalby not necessary anymore, but i want to take care of that part of refactor, because it requires so much old stuff that i want to be sure you don't get stuck in an endless comment ping pong.

ViewportTransform i think is not messy, is a very simple concept camera view, the issue that arise are only for things that we don't want affected by the viewport transform. padding for example and other UI elements developers want to add.

I don't want to redesign everything is an unnecessary risk and a large undertake. For developer too.

Running a test with controls and then approving ( unless my test is the failing test )

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.15 |    76.49 |   86.36 |   82.87 |                                               
 fabric.js |   83.15 |    76.49 |   86.36 |   82.87 | ...,29750,29875,29955-30020,30143,30242,30459 
-----------|---------|----------|---------|---------|-----------------------------------------------

@asturur
Copy link
Member

asturur commented Feb 24, 2022

i think the final drawing is the same:
controls13

and same test run on this code:
controls13

the drawing is broken in both cases, so we are not really breaking anything more

@asturur asturur merged commit 1d447b0 into master Feb 24, 2022
@asturur asturur deleted the minor-use-point branch February 24, 2022 09:16
@ShaMan123
Copy link
Contributor Author

oCoords are probalby not necessary anymore, but i want to take care of that part of refactor, because it requires so much old stuff that i want to be sure you don't get stuck in an endless comment ping pong.

Great

ShaMan123 added a commit that referenced this pull request Mar 2, 2022
commit 109efe5
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Thu Feb 24 11:38:26 2022 +0200

    feat(util): transform utils (#7614)

    * Update misc.js

    * Update misc.js

    * rename

    * better JSDOC

    * Update misc.js

    * Update util.js

    * ci(): lint

    * better JSDOC

    * `sendObjectToPlane`

    * Update misc.js

    * Update util.js

    * Update util.js

    * Update misc.js

    * rename

    * Update misc.js

    * Update util.js

    * Update misc.js

    * remove redundant tests

    * Update util.js

    * Update misc.js

    * Update misc.js

    * Update util.js

    * Update util.js

    * fix(): reversed transform order

    * allow passing null for `sourceObject`

    * Update util.js

    * lint

    * Update misc.js

    * Update misc.js

    * ci: adjust tests to accept error

    * Update misc.js

    * Update util.js

    * build

    * Revert "Update misc.js"

    This reverts commit fb83a71.

    * Update misc.js

    * checkout

    * Update util.js

    * Update misc.js

    * Update util.js

    * typo

    * Update misc.js

    * optional parent

    * refactor around orphan objects

    * Update misc.js

    * add warning

    * Update object_geometry.mixin.js

    * lint

    * rename

    * JSDOC

    * Revert "JSDOC"

    This reverts commit a88b0ab.

    * remove unsafe `calcPlaneMatrix`

    * typo

    * Update misc.js

    * Update misc.js

commit 1d447b0
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Thu Feb 24 11:16:43 2022 +0200

    chore/fix(v6): prerequisites for Group (#7728)

commit f13075c
Author: Andrea Bogazzi <andreabogazzi79@gmail.com>
Date:   Thu Feb 24 10:03:22 2022 +0100

    tests() adding an extra controls test where the group are transformed (#7736)

commit bae062c
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Thu Feb 24 10:10:20 2022 +0200

    chore(): Group prerequisite minor refactor object_origin

commit 23ae1a7
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Wed Feb 23 00:43:36 2022 +0200

    fix(): ensure scaling factor is positive for strokeUniform (#7729)

    * Update object.class.js

    redundant else if

    * added a visual test

    * removed useless file

    * prefer dashes

    * prefer dashes

    * modified golden

    * more tolerance

    Co-authored-by: Andrea Bogazzi <andreabogazzi79@gmail.com>

commit 84e405d
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Mon Feb 21 14:52:07 2022 +0200

    MAJOR chore(v6): neutral prerequisites for fabric.Group rework (#7726)

commit 0c98cee
Author: Andrea Bogazzi <andreabogazzi79@gmail.com>
Date:   Mon Feb 21 08:25:42 2022 +0100

    chore(): update CHANGELOG

commit 6565db1
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Mon Feb 21 07:30:19 2022 +0200

    fix(): add `eraser` to Object state/cache props (#7720)

    * Update eraser_brush.mixin.js

    * Update eraser_brush.mixin.js

commit fd1b0c3
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Sun Feb 20 17:18:19 2022 +0200

    feat(Object.isType): accept multiple `type` (#7715)

commit 4e80e77
Author: Andrea Bogazzi <andreabogazzi79@gmail.com>
Date:   Sun Feb 20 16:12:36 2022 +0100

    updated package.json

commit fc902cb
Author: CommanderRoot <CommanderRoot@users.noreply.github.com>
Date:   Sun Feb 20 13:40:29 2022 +0100

    chore(): Replace deprecated String.prototype.substr() with Array.prototype.slice() (#7696)

    String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated.
    Signed-off-by: Tobias Speicher <rootcommander@gmail.com>

commit 30c0c19
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Sun Feb 20 14:39:15 2022 +0200

    MAJOR feat(fabric.Point): divide, scalarDivide, scalarDivideEquals (#7716)

    * **BREAKING**: divide, scalarDivide, scalarDivideEquals

commit 2d922e1
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Sun Feb 20 14:37:52 2022 +0200

    chore(): use Array.isArray instead of ie6+ workarounds (#7718)

commit 88b425c
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Sun Feb 20 14:24:21 2022 +0200

    MAJOR feat(): Reuse fabric.Point logic for scaling and naming consistency (#7710)

    * fix(Object): object scaling inconsisteny

    **MAJOR**
     **BREAKING** `Object.getObjectScaling`, `Object.getTotalObjectScaling`

commit 7e563c7
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Sun Feb 20 02:19:13 2022 +0200

    chore(): BREAKING Cleanup fabric.Point for v6 (#7709)

    * Update misc.js

    * point **BREAKS** `multiply`

    * Update point.js

    * revert adding error check

commit 4c2e9a6
Author: Shachar <34343793+ShaMan123@users.noreply.github.com>
Date:   Sun Feb 20 01:52:47 2022 +0200

    tests(fabric.animation): fix test reliability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants