Answer the question
In order to leave comments, you need to log in
Canvas how to move an object?
how to move triangle in canvas by top left values
Answer the question
In order to leave comments, you need to log in
Option 1 via matrix offset
ctx.save();
ctx.translate(50,0); // тут координаты смещения
ctx.beginPath();
ctx.moveTo(0,100);
ctx.lineTo(200,100);
ctx.lineTo(100,0);
ctx.closePath();
ctx.fill();
ctx.restore();
var offX = 300;//по х
var offY = 50;//по у
ctx.beginPath();
ctx.moveTo(offX+0,offY+100);
ctx.lineTo(offX+200,offY+100);
ctx.lineTo(offX+100,offY+0);
ctx.closePath();
ctx.fill();
on, vskidku, attach to the coordinates of the triangle, positioning coordinates, such as:
pl + x1, pl + x2, pl + x3
pt + y1, pt + y2, pt + y3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question