L
L
Lev Aleksandrov2021-09-26 13:32:32
JavaScript
Lev Aleksandrov, 2021-09-26 13:32:32

How to make a blur effect when drawing a line on canvas?

I need to achieve the following painting effect on canvas:
6150494c03c10989490007.png

Gradient line of 3 colors.
I found a solution for drawing a gradient line and this is what happened:
615049db60a10609110163.png

I didn’t really go into it, but the essence of the solution seems to be this:
When the mouse moves from one point to another, circles are drawn using the plotLine function. The getColor function is used to calculate the color of the circle.
I tried to add blurs to the drawn circles via ctx.shadowBlur, but it didn't work. I also tried to assign to the circles not the color itself obtained by the getColor function, but a radial gradient from the resulting color passing from the center outward to transparency 0, but it also did not work.

Here is the code:
https://codepen.io/h3ckphy/pen/xxrQGLz

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bingumd, 2021-09-26
@h3ckphy

c.style.webkitFilter = "blur(3px)";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question