color
array so that the image on the left and the image on the right look the same. context.translate(100, 100);
context.fillStyle = "black";
for (let c of color) {
context.fillRect(0, 0, 50, 50);
context.translate(75, 0);
context.fillStyle = c;
}
context.fillRect(200, 200, 100, 100);
context.rotate(Math.PI/4);
context.translate(250, 250);
context.translate(-250, -250);
context.translate(200, 200);
context.translate(-200, -200);
context.translate(0, 60);
context.translate(20, 40);
context.translate(-40, -60);
is equivalent to: . Click to draw a random rectangle in light red based on this line and compare it with the same rectangle drawn in green based on the previous lines. context.scale(4, -5);
context.scale(3, 2);
context.scale(-3, 2);
is equivalent to: . Click to draw a random rectangle in light red based on this line and compare it with the same rectangle drawn in green based on the previous lines. context.rotate(90);
context.rotate(-120);
context.rotate(30);
is equivalent to: . Click to draw a random rectangle in light red based on this line and compare it with the same rectangle drawn in green based on the previous lines. gx
, gy
, rx
, ry
so that the image on the left and the image on the right look the same. context.translate(250, 250);
context.fillStyle = "blue";
drawTriangle(canvas, context);
context.save();
context.rotate(-Math.PI / 2);
context.translate(gx, gy);
context.fillStyle = "green";
drawTriangle(canvas, context);
context.restore();
context.save();
context.translate(rx, ry);
context.rotate(Math.PI / 2);
context.fillStyle = "red";
drawTriangle(canvas, context);
context.restore();
Last Updated: April 15, 2025 at 3:43 PM