HTML canvas making blurry shapes(制作模糊形状的 HTML 画布)
问题描述
我想使用 HTML 制作简单的形状.但是形状需要很大.而且画布是全屏的
I want to make simple shapes using HTML. But the shapes need to be big. And the canvas is in full screen
示例:http://jsfiddle.net/xLgg43s9/1/embedded/result/
代码:
请修复它.
推荐答案
不要通过 CSS 设置画布的大小,这会拉伸画布元素,而不是实际使画布变大.
Don't set the canvas's size through CSS, that stretches the canvas element, instead of actually making the canvas larger.
改用 HTML 属性:
Use HTML attributes, instead:
现在,由于您想将画布设置为 100% 的宽度/高度,这些预设属性对您不起作用,您将不得不使用一些 JS:
Now, since you want to set the canvas to 100% width / height, those pre-set attributes aren't going to do the trick for you, you're going to have to use some JS:
如果您想在调整窗口大小时调整画布大小,建议您查看 this answer.
If you want to have the canvas resize when the window gets resized, I'd suggest you look at this answer.
这篇关于制作模糊形状的 HTML 画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!