How to make something to move the lines by pressing the button to? Как сделать что-бы линии можно было двигать по нажатию кнопки | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to make something to move the lines by pressing the button to? Как сделать что-бы линии можно было двигать по нажатию кнопки

Или её параметры х,у не понимаю как передовать и присваивать параметры <body> <button onclick="ramb()">curios1</button> <canvas id="myCanvas" width="501" height="501"></canvas> <script> function ramb(){ var canvas = document.getElementById("myCanvas"), context = canvas.getContext("2d"); var v = Math.floor(Math.random() + Math.random()+Math.random()*12); var q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m q = context.beginPath(); w = context.moveTo(0, 200); e = context.lineTo(v*27,150); r = context.lineTo(56*v,200); t = context.closePath(); y = context.strokeStyle = "red"; u = context.stroke(); i = 0; o = 1; p = 2; a = 3; s = 4; d = 5; f = 6; g = 7; h = 8; j = 9; //РАМКИ context.beginPath(); context.moveTo(1, 200); context.lineTo(500,200); context.moveTo(0, 0); context.lineTo(0, 500); context.moveTo(500, 0); context.lineTo(0, 0)

21st Apr 2019, 4:26 PM
MakarovDs
1 Answer
+ 1
first clear the canvas https://stackoverflow.com/questions/2142535/how-to-clear-the-canvas-for-redrawing then redraw the line in other location
21st Apr 2019, 4:38 PM
Taste
Taste - avatar