- Drawing Graphics Programs
- Graphic Design Software Free
- Downloadable Drawing Program
Write a Program to draw basic graphics construction like line, circle, arc, ellipse and rectangle.
#include<graphics.h> #include<conio.h> void main() { intgd=DETECT,gm; initgraph (&gd,&gm,'c:tcbgi'); setbkcolor(GREEN); printf('tttnnLINE'); line(50,40,190,40); printf('ttnnnnRECTANGLE'); rectangle(125,115,215,165); printf('tttnnnnnnnARC'); arc(120,200,180,0,30); printf('tnnnnCIRCLE'); circle(120,270,30); printf('tnnnnECLIPSE'); ellipse(120,350,0,360,30,20); getch(); }
Output Reddit elder scrolls legends.
YouiDraw is the open-source vector graphics software that provides a variety of customizable textured brushes to the users. This free vector drawing tool offers modern tools like a pencil for the plain line or sketchy and different color options. With different color and border size, users can shape new text. Try SmartDraw's drawing program, the perfect drawing tool for creating all kinds of great-looking drawings, charts, graphs, and illustrations. Drawing Program - Draw Diagrams and Graphics. Try SmartDraw's drawing program, the perfect drawing tool for creating all kinds of great-looking drawings, charts, graphs, and illustrations. Drawing Program - Draw Diagrams and Graphics Online Site License.
The Graphics object represents a GDI+ drawing surface, and is the object that is used to create graphical images. There are two steps in working with graphics: Creating a Graphics object. Using the Graphics object to draw lines and shapes, render text, or display and manipulate images.
Write a Program to draw animation using increasing circles filled with different colors and patterns.
#include<graphics.h> #include<conio.h> void main() { intgd=DETECT, gm, i, x, y; initgraph(&gd, &gm, 'C:TCBGI'); x=getmaxx()/3; y=getmaxx()/3; setbkcolor(WHITE); setcolor(BLUE); for(i=1;i<=8;i++) { setfillstyle(i,i); delay(20); circle(x, y, i*20); floodfill(x-2+i*20,y,BLUE); } getch(); closegraph(); }
Output
Program to make screen saver in that display different size circles filled with different colors and at random places.
#include<stdio.h> #include<conio.h> #include'graphics.h' #include'stdlib.h' void main() { intgd=DETECT,gm,i=0,x,xx,y,yy,r; //Initializes the graphics system initgraph(&gd,&gm,'c:tcbgi'); x=getmaxx(); y=getmaxy(); while(!kbhit()) { i++; // setfillstyle(random(i),random(30)); circle(xx=random(x),yy=random(y),random(30)); setfillstyle(random(i),random(30)); floodfill(xx,yy,getmaxcolor()); delay(200); } getch(); }
Output
Write a Program to make a moving colored car using inbuilt functions.
#include<graphics.h> #include<conio.h> int main() { intgd=DETECT,gm, i, maxx, cy; initgraph(&gd, &gm, 'C:TCBGI'); setbkcolor(WHITE); setcolor(RED); maxx = getmaxx(); cy = getmaxy()/2; for(i=0;i<maxx-140;i++) { cleardevice(); line(0+i,cy-20, 0+i, cy+15); line(0+i, cy-20, 25+i, cy-20); line(25+i, cy-20, 40+i, cy-70); line(40+i, cy-70, 100+i, cy-70); line(100+i, cy-70, 115+i, cy-20); line(115+i, cy-20, 140+i, cy-20); line(0+i, cy+15, 18+i, cy+15); circle(28+i, cy+15, 10); line(38+i, cy+15, 102+i, cy+15); circle(112+i, cy+15,10); line(122+i, cy+15 ,140+i,cy+15); line(140+i, cy+15, 140+i, cy-20); rectangle(50+i, cy-62, 90+i, cy-30); setfillstyle(1,BLUE); floodfill(5+i, cy-15, RED); setfillstyle(1, LIGHTBLUE); floodfill(52+i, cy-60, RED); delay(10); } getch(); closegraph(); return 0; }
Output
Write a Program to print your name in Hindi script on console output in C.
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,'c:tcbgi'); setbkcolor(9); line(100,100,370,100); line(120,100,120,170); arc(143,100,0,180,23); line(165,100,165,155); arc(150,155,100,0,15); line(180,100,180,170); circle(210,140,10); line(210,130,250,130); circle(280,140,10); line(280,130,330,130); line(330,100,330,170); line(345,100,345,170); ellipse(337,100,0,180,9,18); getch(); }
Output
Drawing Graphics Programs
Write a Program control a ball using arrow keys.
#include<graphics.h> #include<stdio.h> void main() { intgd=DETECT,gm,x,y,r=40; charch; initgraph(&gd,&gm,'C:/TURBOC3/BGI'); setbkcolor(3); x=getmaxx()/2; y=getmaxy()/2; setfillstyle(1,RED); circle(x,y,r); floodfill(x,y,getmaxcolor()); while((ch=getch())!=13) { switch(ch) { case 75: if(x>=r+1) { cleardevice(); circle(x-=10,y,r); floodfill(x,y,getmaxcolor()); } break; case 72: if(y>=r+1) { cleardevice(); circle(x,y-=10,r); floodfill(x,y,getmaxcolor()); } break; case 77: if(x<=(getmaxx()-r-10)) { cleardevice(); circle(x+=10,y,r); floodfill(x,y,getmaxcolor()); } break; case 80: if(y<=(getmaxy()-r-10)) { cleardevice(); circle(x,y+=10,r); floodfill(x,y,getmaxcolor()); } } } getch(); }
Output
Write a Program to implement Digital Clock.
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> struct time t; void display(int,int,int); void main() { int i=0,gd=DETECT,gm,hr,min,sec; clrscr(); initgraph(&gd,&gm,'c:turboc3bgi'); setcolor(GREEN); settextstyle(4,0,7); while(!kbhit()) { gettime(&t); hr=t.ti_hour; min=t.ti_min; sec=t.ti_sec; i++; display(100,100,hr); display(200,100,min); display(300,100,sec); sound(400); delay(30); nosound(); delay(930); cleardevice(); } getch(); } void display(int x,int y,int num) { char str[3]; itoa(num,str,10); settextstyle(4,0,7); outtextxy(180,100,':'); outtextxy(280,100,':'); outtextxy(x,y,str); rectangle(90,90,380,200); rectangle(70,70,400,220); outtextxy(90,250,'Digital Clock'); }
Output
Write a Program to make puzzle game.
#include<iostream.h> #include<dos.h> #include<conio.h> #include<graphics.h> #include<stdio.h> int a[5][5]; int t[16]={0,4,11,12,7,1,15,5,13,6,10,3,2,14,8,9}; int test[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; struct pos { int h,v; } p[4][4]; int row=4,col=4; void game(int); //MOVEMENT void rec(); //DRAWING RECTANGLE void pri(); //PRINTING NUMBERS INITIALLY int getkey(); // TO TRACE KEY PRESSED inline void space() { cout<<'; } inline void print(int r,int c) { cout<<a[r][c]; } void init(); //TO STORE CO-ORDINATES int stop(); // STOPING CRITERION void gopr(int,int); //TO PRINT NUMBER IN GAME void main() { int gm=DETECT,gd=DETECT; initgraph(&gm,&gd,'c:turboc3bgi'); int d,cr=1; init(); rec(); print(); while(cr!=16) { d=getkey(); game(d); cr=stop(); } settextstyle(10,0,1); outtextxy(400,300,'You are winner!'); getch(); } void rec() { setcolor(5); for(int i=0;i<200;i+=50) { for(int j=0;j<240;j+=60) rectangle(j+100,i+100,j+50,i+60); } } void pri() { int k=1; for(int x=0,i=6;x<4;x++,i+=3) { for(int y=0,j=10;y<4&&k<16;y++,j+=7,k++) { gotoxy(p[x][y].h,p[x][y].v); cout<<a[x][y]; } } } int getkey() { union REGS i,o; while(!kbhit()); i.h.ah=0; int86(22,&i,&o); return(o.h.ah); } void init() { int k=1; for(int x=0,i=6;x<4;x++,i+=3) { for(int y=0,j=10;y<4;y++,j+=7) { p[x][y].h=j; p[x][y].v=i; a[x][y]=t[k++]; } } } void game(int s) { int r=row-1; int c=col-1; if(s77 &&c!=0) //right { col--; a[r][c]=a[r][c-1]; gopr(r,c-1); space(); gopr(r,c); print(r,c-1); } if(s80 && r!=0) //down { row--; a[r][c]=a[r-1][c]; gopr(r-1,c); space(); gopr(r,c); print(r-1,c); } if(s75 && c!=3) //left { a[r][c]=a[r][c+1]; col++; gopr(r,c+1); space(); gopr(r,c); print(r,c+1); } if(s72 &&r!=3) //up { a[r][c]=a[r+1][c]; row++; gopr(r+1,c); space(); gopr(r,c); print(r+1,c); } } void gopr(int x, int y) { gotoxy(p[x][y].h,p[x][y].v); } int stop() { int k=0,d=1; for(int x=0;x<4;x++) { for(int y=0;y<4;y++) { if(a[x][y]test[k]) d++; k++; } } return d; }
Output
Write a Program to implement bouncing ball using sine wave form.
#include<stdio.h> #include<graphics.h> #define HEIGHT getmaxy() #define WIDTH getmaxx() #define GROUND 450 #define MAXHEIGHT 420 void main() { int x,y=0,t=MAXHEIGHT,c=1; int gd=DETECT,gm; initgraph(&gd,&gm,'C:T urboC3BGI'); for(x=40;x<=getmaxx();x=x+2) { //Draw Ground rectangle (0,MAXHEIGHT,getmaxx(),MAXHEIGHT+5); floodfill (5,MAXHEIGHT+3,WHITE); //Draw Ball pieslice(x,y,0,360,20); //floodfill(x,y,RED); delay(100); if(y>MAXHEIGHT-20) { c=0; t=t-40; } if(y<=(MAXHEIGHT-t)) { c=1; } if(t>=40) y=y+(c? 15:-15); cleardevice(); //Exit upon keypress if(kbhit()) break; } getch(); }
Output
Write a Program to implement Bouncing Ball in vertical direction.
#include <stdio.h> #include <conio.h> #include <graphics.h> #include <dos.h> int main() { int gd = DETECT, gm; int i, x, y, flag=0; initgraph(&gd, &gm, 'C:TCBGI'); x = getmaxx()/2; y = 30; while (!kbhit()) { if(y >= getmaxy()-30 || y <= 30) flag = !flag; /* draws the gray board */ setcolor(RED); setfillstyle(SOLID_FILL, RED); circle(x, y, 30); floodfill(x, y, RED); delay(50); cleardevice(); if(flag) { y = y + 5; } else { y = y - 5; } } getch(); closegraph(); return 0; }
Output
Write a program of Translation, Rotation, and Scaling using Composite Transformation.
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> int x1,y1,x2,y2,x3,y3,a,b; void draw(); void rotate(); int main(void) { int gd=DETECT,gm; initgraph(&gd,&gm,'C:TCBGI'); printf('Enter first co-ordinate value for triangle:'); scanf('%d%d',&x1,&y1); printf('Enter second co-ordinatevalues for triangle:'); scanf('%d%d',&x2,&y2); printf('Enter third co-ordinate valuesfor triangle:'); scanf('%d%d',&x3,&y3); draw(); getch(); rotate(); getch(); return 0; } void draw() { line(x1,y1,x2,y2); line(x2,y2,x3,y3); line(x3,y3,x1,y1); } void rotate() { int a1,a2,a3,b1,b2,b3; float angle; printf('Enter the rotation angle co-ordinates:'); scanf('%f',&angle); cleardevice(); angle=(angle*3.14)/180; a1=a+(x1-a)*cos(angle)-(y1-b)*sin(angle); b1=b+(x1-a)*sin(angle)+(y2-b)*cos(angle); a2=a+(x2-a)*cos(angle)-(y1-b)*sin(angle); b2=b+(x2-a)*sin(angle)+(y2-b)*cos(angle); a3=a+(x3-a)*cos(angle)-(y1-b)*sin(angle); b3=b+(x3-a)*sin(angle)+(y2-b)*cos(angle); printf('ROTATION'); printf('n Changed coordinatesn'); printf('%d %dn%d %dn%d %d',a1,b1,a2,b2,a3,b3); line(a1,b1,a2,b2); line(a2,b2,a3,b3); line(a3,b3,a1,b1); }
Output
Write a program to draw a Circle using midpoint implementation Method.
Graphic Design Software Free
#include<stdio.h> #include<graphics.h> void drawcircle(int x0, int y0, int radius) { int x = radius; int y = 0; int err = 0; while (x >= y) { putpixel(x0 + x, y0 + y, 7); putpixel(x0 + y, y0 + x, 7); putpixel(x0 - y, y0 + x, 7); putpixel(x0 - x, y0 + y, 7); putpixel(x0 - x, y0 - y, 7); putpixel(x0 - y, y0 - x, 7); putpixel(x0 + y, y0 - x, 7); putpixel(x0 + x, y0 - y, 7); if (err <= 0) { y += 1; err += 2*y + 1; } if (err > 0) { x -= 1; err -= 2*x + 1; } } } void main() { int gdriver=DETECT, gmode, error, x, y, r; initgraph(&gdriver, &gmode, 'c:turboc3bgi'); printf('Enter radius of circle: '); scanf('%d', &r); printf('Enter co-ordinates of center(x and y): '); scanf('%d%d', &x, &y); drawcircle(x, y, r); getch(); }