Cg Practical
Cg Practical
#include <graphics.h>
#include <conio.h>
int main() {
return 0;
}
2. Program To Draw Circle.
#include <graphics.h>
#include <conio.h>
int main() {
return 0;
}
3. Program To Draw Rectangle.
#include <graphics.h>
#include <conio.h>
int main() {
return 0;
}
4.Program To Implementation Flood Fill.
#include <graphics.h>
#include <conio.h>
if (currentColor == oldColor) {
putpixel(x, y, newColor);
int main() {
getch();
closegraph();
return 0;
}
5. Program To Draw Ellipse.
#include <graphics.h>
#include <conio.h>
int main() {
setcolor(WHITE);
// Draw an ellipse
return 0;
}
6. Program To Implement 2-D Mirror Reflection.
#include <graphics.h>
#include <conio.h>
#include <dos.h>
void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color) {
setcolor(color);
int main() {
// Draw axes
getch();
closegraph();
return 0;
}
7. Program To Draw A Smile.
#include <graphics.h>
#include <conio.h>
int main() {
// Face
setcolor(YELLOW);
setfillstyle(SOLID_FILL, YELLOW);
// Eyes
setcolor(BLACK);
setfillstyle(SOLID_FILL, BLACK);
fillellipse(centerX - 35, centerY - 30, 10, 15); // Left eye
// Smile (arc)
setcolor(RED);
// Label
setcolor(WHITE);
getch();
closegraph();
return 0;
}
8. Program To Implement 2-D Shearing.
#include <graphics.h>
#include <conio.h>
void drawRectangle(int x1, int y1, int x2, int y2, int color) {
setcolor(color);
int main() {
// Shearing factors
setcolor(GREEN);
line(x1_yshear, y1_yshear, x2_yshear, y2_yshear);
getch();
closegraph();
return 0;
}
9. Program To Draw Circle Using Bresenham’s Algorithm.
#include <graphics.h>
#include <conio.h>
#include <dos.h>
putpixel(xc + x, yc + y, WHITE);
putpixel(xc - x, yc + y, WHITE);
putpixel(xc + x, yc - y, WHITE);
putpixel(xc - x, yc - y, WHITE);
putpixel(xc + y, yc + x, WHITE);
putpixel(xc - y, yc + x, WHITE);
putpixel(xc + y, yc - x, WHITE);
putpixel(xc - y, yc - x, WHITE);
int x = 0;
int y = r;
int d = 3 - 2 * r;
while (x <= y) {
if (d < 0) {
d = d + 4 * x + 6;
} else {
d = d + 4 * (x - y) + 10;
y--;
x++;
int main() {
int yc = getmaxy() / 2;
getch();
closegraph();
return 0;
}
10. Program To Implement 2-D Translation.
#include <graphics.h>
#include <conio.h>
void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color) {
setcolor(color);
int main() {
// Translation factors
getch();
closegraph();
return 0;