0

How can I create a button to draw with gradient?

https://code.sololearn.com/WB0OWKdoPrmh/?ref=app

30th Jun 2018, 7:33 AM
B.D
B.D - avatar
4 odpowiedzi
+ 8
for that you need to gradually switch color of the brush on each stroke
30th Jun 2018, 9:16 AM
Burey
Burey - avatar
+ 7
if you want to change the canvas background here's how i did it one of my codes you can play around with the randomCanvasColor function for different results all it does is build a random string with a new gradient style var canvas = document.getElementById("canvas"); function randomCanvasColor(){ canvas.style.background = "linear-gradient("+randColor()+","+randColor()+","+randColor()+","+randColor()+","+randColor()+")"; } function randColor(){ // generates random color string var vec="0123456789abcdef"; var color="#"; for(var i=0;i<6;i++){ color+=vec[randVal(0,vec.length-1)]; } return color; }
30th Jun 2018, 8:51 AM
Burey
Burey - avatar
+ 2
If you want to draw line in gradient color, use createLinearGradient function to create strokeStyle first. https://code.sololearn.com/Wu6PXIR28ht8/?ref=app
1st Jul 2018, 10:57 AM
Calviղ
Calviղ - avatar
0
I wanted to paint with gradient
30th Jun 2018, 8:55 AM
B.D
B.D - avatar