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

Free drawing on zoomed in canvas bug #4299

Closed
bart1337 opened this issue Sep 12, 2017 · 20 comments
Closed

Free drawing on zoomed in canvas bug #4299

bart1337 opened this issue Sep 12, 2017 · 20 comments
Labels

Comments

@bart1337
Copy link

Issue:

When canvas is zoomed in (zoomToPoint) drawn line or point is moved few pixels away. Tested it on 370x370 image scaled to 336x336 -> when clicked on bottom right corner (370, 370) pointer returns (367,367). Adding code pen for tests. Just zoom in (scroll) and click on canvas. Drawn circle will be few pixels away from pointer.

https://codepen.io/anon/pen/EwYzjp

@asturur
Copy link
Member

asturur commented Sep 12, 2017

Your codepen on macos/chrome keep refreshing like crazy. please check it.

@bart1337
Copy link
Author

Have no idea what may cause it.. What about fiddle?
https://jsfiddle.net/kjudhjgq/

@asturur
Copy link
Member

asturur commented Sep 12, 2017

jsfiddle is ok! could you put the buttons in english please?

@bart1337
Copy link
Author

bart1337 commented Sep 12, 2017

They're not important... forgot to remove them.

EDIT: Updated.

@asturur
Copy link
Member

asturur commented Sep 16, 2017

I cannot see the bug. Can you give me a clear way to reproduce the bug?

@bart1337
Copy link
Author

Just open fiddle, zoom in (scroll up) and left click to draw. Make just one click and you will notice that the center of drawn circle is few pixels away from pointer.

@asturur
Copy link
Member

asturur commented Sep 16, 2017

image

It happens because the single click create that path that is not centered on the click.
But in general if you use free drawing as a pencil it is positioned correctly.

If you need to draw just single circles, would be better if you create a specialized brush that draw just a single circle.

I do not think i have something to fix here.
If you think something is wrong and i missed it, let's continue the topic

@asturur
Copy link
Member

asturur commented Sep 16, 2017

Probably fixing the code and ermoving the Q step, would fix the issue.

@bart1337
Copy link
Author

Well it is not just about circles, when you draw a line the center of it is few pixels away. That may be annoying when you need to draw line close to something

@asturur
Copy link
Member

asturur commented Sep 16, 2017

Is not lack of good will. I cannot see this de-centering. Please show me a gif or something where i can see the full process.

@asturur
Copy link
Member

asturur commented Sep 16, 2017

wait i see a high high zoom level there is a displacemente

@bart1337
Copy link
Author

Yes, scroll up to maximum zoom and then to even increase the displacement move to the bottom right of canvas (shift + mouse move).

@bart1337
Copy link
Author

Probably further away from center the bigger gets displacement.

@asturur
Copy link
Member

asturur commented Sep 16, 2017

i did not notice you are on 1.7.18

This needs custom investigation and fix. 2.0 beta version is ok.

@bart1337
Copy link
Author

Getting same result on 2.0. Also when I end drawing a path (mouse up) it is moved few pixels away (even without zooming). That's why I did not use it.

@asturur
Copy link
Member

asturur commented Sep 16, 2017

Got a nice fix for 2.0 at least avoiding the small lines and creating good circles.

Sometimes is possible to do something like that:

image

sort of triggering a mouse move without movement, or a so small movement that there is not change in coords in float, and the drawing of chrome gets crazy.

@asturur
Copy link
Member

asturur commented Sep 17, 2017

This is not solved.
While other defect are solved, in your fiddle, even simplified this problem occurs.
https://jsfiddle.net/kjudhjgq/3/

@asturur
Copy link
Member

asturur commented Sep 17, 2017

ok is the border.
Do not apply style to the canvas with the border.
Css will shrink the canvas in a lesser space to make space for the border. that half pixel pixel of border at the edged, make so at high zoom level to get a big displacement.

@asturur asturur closed this as completed Sep 17, 2017
@bart1337
Copy link
Author

bart1337 commented Sep 19, 2017

Removed borders, outlines and everything and looks like it is smaller displacement now, but still exists :(
EDIT:Hmm it must be something else with my code then. Removed border on fiddle and it's okay.

EDIT2: Okay it was because of resizing canvas to sizes like 200.XX px. Rounded it and it is now okay.

@titusfx
Copy link

titusfx commented Dec 5, 2022

@bart1337 did you fix the problem? I've been having the same issue, I'm drawing lines ok, but when I do zoom, and then I come back to initial zoom, the problem persists. And I'm not using free drawing. I'm doing this example:
First I started drawing lines and then follow the tutorial of this link http://fabricjs.com/fabric-intro-part-5 and then the pointer is shifted by a good amount. Event going back to zoom=1

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

3 participants