-
-
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
clone and cloneAsImage creates objects larger than original (retina related) #3041
Comments
can you make a fiddle that shows it please? |
I'm having a hard time simplifying my code. On looking deeper, it seems like SVG paths and SVG images in general is misbehaving, even without cloning. |
It seems like scaling SVG images before adding to patterns and static canvases also behaves differently. I can't seem to get SVG images to resize/scale and then be applied as patterns correctly. |
@asturur |
Update: |
I ended up deactivating retina support as I encountered issues with todataurl not behaving correctly. Now everything works fine.
From: jhiswin [email protected] Update: — |
we are improving retina screen support. fabric.canvas.enablerRetinaScaling = false; should do the trick. |
Yes that's what I resorted to. |
Just an FYI, StaticCanvas and patterns are also affected. Reactivating it causes problems, even when scaling is done, so I had to permanently turn off retina on the StaticCanvas being used as a pattern fill, which for the most part fixed the problems. For everything else I could just rescale (scaleToHeight) after cloning, which maintains the nice retina quality. |
But, SVG shapes on the main canvas are significantly sharper than before (I just have to remember to scaleToHeight(originalHeight) after cloning), which is quite nice. It'd be great if there was a workaround for sub-Canvases and pattern fills. |
would you so kind to open a jsfiddle showing patterns problems so i can mark this as a bug? |
IIRC: create a rect, copy it as an image position it at the same position as the rect. On standard desktop no issue, both are same position and same size. On a retina the image is half size the rect and not correctly positionned (iirc). |
@butch2k I posted a fiddle for that already. asturur is talking about another issue related to patterns. Everything will work as expected as long as the StaticCanvas you use for the pattern has retina off at all times. |
@jhiswin Yes i encountered it as well when using a hexagon pattern fill using an svg pattern. I'm under the feeling that it's related to the way dpr is handled in the __toDataURLWithMultiplier function. on a retina the multiplier is passed to the function being multiplied by the dpr. It's then divided back to it's original value (newZoom) ???? Basically it means you do not retinascale when dataURLing. To dataURL, multiplying the multiplier by the dpr
And __toDataURLWithMultiplier setting it back to default multiplier: __toDataURLWithMultiplier: function(format, quality, cropping, multiplier) { |
@butch2k Ah that makes sense. That explains why turning off retina scaling on a StaticCanvas works around the problem. |
@asturur After further testing: turning off retina during cloneAsImage was enough to resolve the pattern issue (I clone multiple times and had turned it off in the wrong place). Do you still need a fiddle for patterns? |
i think that cloneAsImage should be retina disabled unless required by dev with a parameter. Otherwise cloning the same object mutipletime will end in a bigger and bigger object everytime. |
@butch2k that newzoom variable is an hack to let the shadow scale properly. when we dataurl we create a new canvas with all the stuff over and i disable the retinaScaling but i enable a zoom that is twice the original. So that |
This worked normally in 1.5.0 (unless this is an intended breaking change?).
Both clone() and cloneAsImage() creates a cloned object that is larger than the original.
The text was updated successfully, but these errors were encountered: