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
Canvas blur after rescale page #7502
Comments
Try using setDimensions
|
@rockerBOO i've try it, but it not work for me. I did try use only After call |
I have also used this option. Don't try to adjust the lowerCanvasEl or upperCanvasEl. They are generally abstracted away where you shouldn't need to access them. You can infer things from them but manually adjusting is probably going to cause some conflict. |
@rockerBOO unfortunately I adjust I've tried |
In my example I run that code on |
@rockerBOO is you just set new size while |
Slapped this example together. <!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/fabric@4.6.0/dist/fabric.min.js"></script>
<style>
body { margin: 0; }
</style>
</head>
<body>
<canvas id="canvas1"></canvas>
<script>
window.onload = () => {
const canvas = new fabric.Canvas("canvas1");
canvas.add(new fabric.Circle({ radius: 100, fill: 'red', top: 100, left: 100 }))
const onResize = () => {
canvas.setWidth(window.innerWidth)
canvas.setHeight(window.innerHeight)
}
window.addEventListener('resize', onResize)
onResize()
}
</script>
</body>
</html> |
@rockerBOO i tried your example Reproduce steps:
|
Ahh yes I see what you're saying now. Sorry about that. I have noticed this as long as I have used it but just thought it was a canvas thing. |
@rockerBOO it's fine. What you think about it? It seems like bug? |
hi! |
@asturur hi. Can we implement some knob to manual update values which affect on this problem while render? I think little things like this is very important for high quality projects. Thanks for attention |
we should avoid setting retina scaling to less than 1 in fabricjs, since there are no browsers that have more css pixels than real pixels. i think you can open a pr by yourself, the function is called getRetinaScaling and should never return a number smaller than 1. |
@asturur thanks for explaining bug mechanic. I've create PR #7537 with fix Also i want to leave here solution for people from future who have this bug. As told @asturur cause in const onResize = () => {
// update devicePixelRatio
fabric.devicePixelRatio = fabric.window.devicePixelRatio ||
fabric.window.webkitDevicePixelRatio ||
fabric.window.mozDevicePixelRatio ||
1;
canvas._initRetinaScaling();
// re-render canvas with new quality
canvas.requestRenderAll();
}
window.addEventListener('resize', onResize) It's should fix problem. Also, fabric is provide a |
on my projects i attach a resize event on the canvas container and then i use setDimension to adapt the canvas. |
@asturur yes, call Btw, what you think about some hook for It may be useful for cases like this bug, when some inner variable is more not actual after some changes which we can't predict. |
Thanks guys, I think this solves an issue in my project. |
Canvas is not rescale content after resize page.
When we load web page with 50% page zoom and then set zoom to 100% canvas looks very bad like low resolution pucture.
I did try to manually rescale fabricjs inner objects while resize page like that:
It's just resize inner canvases to consider actual size.
And this fix problem, but controls to resize objects are render wrong and i can't fix it.
If you have solution, tell about it.
Seems it impossible to fix on library user side.
As i think, we have some variable inside fabricjs which is not update after rescale page and always draw picture as while initiation. Maybe we should update this variables on the library level?
Version
3.6.0
Test Case
It reproduce on any page with fabricjs, try it on the http://fabricjs.com/
Information about environment
All browsers
Steps to reproduce
Expected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: