how to make move able triangle in canvas js

Solutions on MaxInterview for how to make move able triangle in canvas js by the best coders in the world

showing results for - "how to make move able triangle in canvas js"
Hugo
26 Oct 2020
1        function drawTrianlge(e) {   // add this with event listener...
2            var bx = fe.offsetX;
3            var by = fe.offsetY;
4            var x = e.offsetX;
5            var y = e.offsetY;
6            var takeLineLen = Math.abs((bx + by) - (x + y));
7            context.beginPath();
8            context.moveTo(bx, by);
9            context.lineTo(x, y);
10            context.moveTo(x, y);
11            context.lineTo(takeLineLen - x / 2 , y);
12            context.moveTo(takeLineLen - x / 2 , y);
13            context.lineTo(takeLineLen - y / 2 , by);
14            context.stroke();
15            context.closePath();
16        }
Domenico
24 Feb 2019
1        function drawTrianlge(e) {     // add eventlistener!!!
2            var bx = fe.offsetX;
3            var by = fe.offsetY;
4            var x = e.offsetX;
5            var y = e.offsetY;
6            context.beginPath();
7            context.moveTo(bx, y);       
8            context.lineTo(x, y);
9            context.lineTo(x, by);
10            context.closePath();
11            context.stroke();            
12        }