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

Viewport Transform and clipping #2629

Closed
inssein opened this issue Nov 16, 2015 · 8 comments
Closed

Viewport Transform and clipping #2629

inssein opened this issue Nov 16, 2015 · 8 comments
Assignees
Labels

Comments

@inssein
Copy link
Contributor

inssein commented Nov 16, 2015

I was just testing out the latest build of fabric.js with my application, and ran into a small issue.

Bug is caused by PR: #2580

@asturur Why do we inverse the viewport transform before rendering the controls? This pretty much breaks for everyone who has zoomed the canvas.

@asturur
Copy link
Member

asturur commented Nov 16, 2015

i ll check again, i was sure i tested even that.
we invert the viewport as it was before, because otherwise the strokewidth of controls would get multiplied by the scaling factor.

i m on code later, i will check it.
did you have a ready fiddle to help me?

@inssein
Copy link
Contributor Author

inssein commented Nov 16, 2015

@asturur don't have a public build of fabric that has your commit yet, but if you setZoom() on the canvas, it should be fairly obvious.

For example, when I canvas.setZoom(0.25), my controls are four times the size.

@asturur
Copy link
Member

asturur commented Nov 17, 2015

http://jsfiddle.net/asturur/7fsw81mp/7/

link to build file

http://www.deltalink.it/andreab/fabric/fabric.js

i cannot find the bug.
Check please, i think you download the library when i put inside the setTransform methods.

@inssein
Copy link
Contributor Author

inssein commented Nov 17, 2015

@asturur took me a while to figure out, but I re-created the error. The combination of settings that cause it are canvas.controlsAboveOverlay = true and performing a canvas.clipTo().

Fiddle: https://jsfiddle.net/7fsw81mp/8/

@asturur
Copy link
Member

asturur commented Nov 17, 2015

Going to check now.
clipTo + canvas viewportTransform has an undefined behaviour in my opinion.
We can still check on original kitchensink.

@asturur asturur changed the title drawControls and Retina Scaling Viewport Transform and clipping Nov 17, 2015
@asturur
Copy link
Member

asturur commented Nov 17, 2015

Ok i see the mistake.
If we are clipping, the viewportTransform is inside the "save + restore" pair of clipping.
So if we draw controls after overlay, and overlay is after clipping restore, the mistake happens.

Should clipping be influenced by canvasZoom? ( i think yes).
if yes we move viewportTransform before clipping and the problem fixes by itself.
if no ve should reinitialize the viewportTransform after restoring the overlay.

Same problem for for overlay: shoudl overlay be influenced by canvas zooming? as of now if we are clipping it is not influencede, if we do not clip it is. ( with or without controlsAboveOverlay).

Thank for spotting this.

@asturur
Copy link
Member

asturur commented Nov 17, 2015

Ok effectively we the renderAll changes i messed the order of operation.
pre changes order was:

clip.
draw background
apply viewport
render objects
remove viewport
draw controls *
stop clipping
draw overlay
draw controls *

(*just one occurence)

I m restoring the normal behaviour with a PR.
in the fiddle you posted the library is already fixed and looks good.

@asturur asturur mentioned this issue Nov 17, 2015
@asturur asturur added the bug label Nov 17, 2015
@asturur asturur self-assigned this Nov 17, 2015
@inssein
Copy link
Contributor Author

inssein commented Nov 17, 2015

thanks @asturur !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants