gpt4 book ai didi

canvas - 为什么不赞成使用context2d.backingStorePixelRatio?

转载 作者:行者123 更新时间:2023-12-03 14:37:59 41 4
gpt4 key购买 nike

根据Paul Lewis的文章High DPI Canvas:您需要考虑context.backingStorePixelRatio来解决模糊问题。

如果不建议使用此属性, Dart 能否解决高清设备上的模糊问题?

最佳答案

我认为完全一样的事情,就Issue Tracker而言:

Yes, so the article was written back when Safari had a backing store ratio of 2. It's always been 1 in Chrome.

As you say the approach for dealing with this is:

canvas.width = width * window.devicePixelRatio;
canvas.height = height * window.devicePixelRatio;

canvas.style.width = width + 'px';
canvas.style.height = height + 'px';

Where width and height are however you want them (probably window.innerWidth & innerHeight for full viewport shenanigans.)

Then you just need to adjust for the fact that you upscaled the canvas with:

ctx.scale(window.devicePixelRatio, window.devicePixelRatio);



因此,您有解决方案。

关于canvas - 为什么不赞成使用context2d.backingStorePixelRatio?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24332639/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com