Program to Draw Line
[Link](50, 50);
[Link](200, 50);
[Link]();
Program to Draw Circle
[Link]();
[Link](150, 100, 50, 0, 2 * [Link]);
[Link]();
Program to Draw Rectangle
[Link](100, 100, 150, 80); // (x, y, width, height)
Program to Implement Flood Fill
Use getImageData() and putImageData() with a recursive or stack-based approach.
Full implementation can be provided if needed.
Program to Draw an Ellipse
[Link]();
[Link](200, 150, 80, 40, 0, 0, 2 * [Link]);
[Link]();
Program to Implement 2-D Mirror Reflection
[Link]();
[Link](-1, 1); // Reflect over Y-axis
[Link](-[Link], 0);
[Link](100, 100, 100, 50);
[Link]();
Program to Draw a Smile
// Face
[Link](200, 200, 100, 0, 2 * [Link]);
// Eyes
[Link](160, 170, 10, 0, 2 * [Link]);
[Link](240, 170, 10, 0, 2 * [Link]);
// Smile
[Link](200, 210, 50, 0, [Link]);
[Link]();
Program to Implement 2-D Shearing
function shear(x, y, shx, shy) {
return [x + shx * y, y + shy * x];
}
Program to Draw Circle using Bresenhams Algorithm
function drawCircle(xc, yc, r) {
let x = 0, y = r;
let d = 3 - 2 * r;
plotCirclePoints(xc, yc, x, y);
while (y >= x) {
x++;
if (d > 0) {
y--;
d += 4 * (x - y) + 10;
} else {
d += 4 * x + 6;
}
plotCirclePoints(xc, yc, x, y);
}
}
Program to Implement 2-D Translation
function translatePoint(x, y, tx, ty) {
return [x + tx, y + ty];
}