Posts

Showing posts from November, 2020

IMPLEMENTATION OF BRESENHAM LINE DRAWING ALGORITHM USING C++

Image
 IMPLEMENTATION OF BRESENHAM LINE DRAWING ALGORITHM USING C++ CODE: #include<stdio.h> #include<graphics.h> void drawline(int,int,int,int); int abs(int n){     return n<0?-n:n; } void swap(int *a, int *b){     *a = (*a+*b) - (*b=*a); } int main(){     int x1, x2, y1, y2;     printf("Enter the first point ");     scanf("%d%d",&x1,&y1);     printf("Enter the second point ");     scanf("%d%d",&x2,&y2);     int gd=DETECT, gm;     initgraph(&gd,&gm,NULL);     drawline(x1,y1,x2,y2);     getch();     closegraph(); } void drawline(int x1, int y1, int x2, int y2) {     int dx, dy, p, xs, ys, xe, ye, x, y;     dx=x2-x1;     dy=y2-y1;     p=2*dy-dx;     if(abs(dx)>=abs(dy)){         if(dx>=0){             x = xs = x1, y = ys = y1, xe...

C++ PROGRAM TO IMPLEMENT CIRCLE WITH GRAPHICS

Image
Here is the implementation of a user defined circle using c++ code.   CODE: //Implementation of circle in computer graphics using c++ //created by Abhijt, 10/11/2020 #include<graphics.h> #include<stdio.h>   //defining pixel function to color pixels void pixel(int xc,int yc,int x,int y) {                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-...