-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Override devicePixelRatio scaling #110
Comments
I don't think the change would be too big. Here is an example plus 4 other lines need changing. static #setupCanvas(selector, config) {
// previous code...
// NEW DPI CONFIG USED HERE
canvas.width = (config.width || canvas.width) * (config.dpr || window.devicePixelRatio);
canvas.height = (config.height || canvas.height) * (config.dpr || window.devicePixelRatio);
canvas.style.touchAction = 'none';
return canvas;
} |
Hey @Innders - sorry I'm only just getting to this, it's been a busy few weeks. I think this is a great idea and I'd love to add it in the next minor version. The only change I'd make to your proposal is to call the config option |
and thank you for the suggestion! |
I totally agree with the option name, I realized dpr was unclear as soon as I started using it. I tried this out on a fork and it works really well. |
@Innders the |
User Story
You are drawing over a 4K image to make some annotations. The canvas container size is less than 4K, let's say 1080px. Once the drawing has finished you want to export the full image at 4K with annotations included. The canvas must be scaled up to 4K to match the intrinsic size of the image.
The result is you end up with blurry lines.
Solution
window.devicePixelRatio
is taken into account to scale up the canvas to ensure it stays sharp. Could this same method be used to scale the canvas by any factor?It would just require a new configuration argument called
dpr
.If you want the annotation to have 4 times the resolution that you are actually drawing at (in the window) then you could pass
dpr=4
.Do you think this would work?
The text was updated successfully, but these errors were encountered: