She*_*kan 2 javascript glow html5-canvas
是否可以在已经绘制的画布上添加发光效果而无需自己计算?(使用渐变、阴影或其他东西......)
我尝试通过将画布作为图像绘制到不同的画布上,然后将其绘制回来并添加阴影来添加发光效果。它的问题在于它取决于阴影周围的像素数量 - 因为它使图像模糊 - 所以这还不够好。
这里有一个网站介绍了画布文本的发光效果以及其他印刷效果。
这是发光效果的要点:
// Assuming your canvas element is ctx
// Color of the shadow; RGB, RGBA, HSL, HEX, and other inputs are valid.
ctx.shadowColor = "red"; // string
// Horizontal distance of the shadow, in relation to the text.
ctx.shadowOffsetX = 0; // integer
// Vertical distance of the shadow, in relation to the text.
ctx.shadowOffsetY = 0; // integer
// Blurring effect to the shadow, the larger the value, the greater the blur.
ctx.shadowBlur = 10; // integer
Run Code Online (Sandbox Code Playgroud)