We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
关于小程序绘制并生成图片后模糊的解决方法,目前最好的解决方法是当绘制一个600*400的海报,则放大一倍尺寸为1200*800,但这种方法使得每次定义尺寸或者偏移值时,都得计算一遍(num*2)
600*400
1200*800
例如:
dp.canvas.width = 300 * 2; dp.canvas.height = 300 * 2; dp.draw((ctx) => { ctx.fillStyle = "#fff"; ctx.fillRect(0, 0, 300 * 2, 300 * 2); });
又或者:
const st2 = (size) => size * 2; dp.canvas.width = st2(300); dp.canvas.height = st2(300); dp.draw((ctx) => { ctx.fillStyle = "#fff"; ctx.fillRect(0, 0, st2(300) st2(300); });
在我看来,无论是哪种方法,都使工作量大量的增加,目前有个想法,就是使用Object.defineProperty和来new Proxy动态的修改内容。
Object.defineProperty
new Proxy
dp.canvas.width = 300; // dp.canvas.width = 600 dp.canvas.height = 300; // dp.canvas.width = 600 dp.draw((ctx) => { ctx.fillStyle = "#fff"; ctx.fillRect(0, 0, 300, 300); // ctx.fillRect(0, 0, 600, 600) });
但这无疑会增加影响先有api的稳定性,并且在一些特定场景就会出现不合理的情况。
dp.canvas.width = 300; // dp.canvas.width = 600 dp.canvas.height = 300; // dp.canvas.width = 600 dp.draw((ctx) => { ctx.fillStyle = "#fff"; ctx.fillRect(0, 0, dp.canvas.width, dp.canvas.height); // ctx.fillRect(0, 0, 1200, 1200) });
在此,如何更好的解决图片模糊的问题?
The text was updated successfully, but these errors were encountered:
scale放大
Sorry, something went wrong.
const multi = 3 dp.canvas.width = multi*dp.canvas.width dp.canvas.height = multi*dp.canvas.height dp.ctx.scale(multi, multi)
同上,scale可以解决
No branches or pull requests
关于小程序绘制并生成图片后模糊的解决方法,目前最好的解决方法是当绘制一个
600*400
的海报,则放大一倍尺寸为1200*800
,但这种方法使得每次定义尺寸或者偏移值时,都得计算一遍(num*2)例如:
又或者:
在我看来,无论是哪种方法,都使工作量大量的增加,目前有个想法,就是使用
Object.defineProperty
和来new Proxy
动态的修改内容。例如:
但这无疑会增加影响先有api的稳定性,并且在一些特定场景就会出现不合理的情况。
在此,如何更好的解决图片模糊的问题?
The text was updated successfully, but these errors were encountered: