C – Practical System Programming for Graphics in C.

Practical System Programming for Graphics in C

By Shritam Bhowmick
Web Application Penetration Tester
LinkedIn: https://www.linkedin.com/profile/view?id=281014248&trk=nav_responsive_tab_profile
Academia: https://independent.academia.edu/ShritamBhowmick
Facebook: https://www.facebook.com/coded32

This is an introduction post for “Graphics and Internet” for WBUT 2014, which includes C as system programming and the underlying source code concepts for drawing basic graphics using C. Earlier in this post, I discussed data-structures in C for WBUT University in details which covered the practical aspects of year 2014. This post in contrary will mention the graphical aspect of the C programming keeping in mind the practical labs. I am glad I could post as far as the syllabus is concerned (which is really outdated as discussed in the last post), but this will help the current students who could have a look here after 2014 passes.

===========================================================================

1.) Draw a Basic Circle:

#include
#include

main()
{
int gd = DETECT, gm;

initgraph(&gd, &gm, "C:TCBGI");

circle(100, 100, 50);

getch();
closegraph();
return 0;
}

===========================================================================

2.) Draw a Rainbow

#include
#include
#include
#include

void main()
{
int gdriver = DETECT,gmode;
int x,y,i;
initgraph(&gdriver,&gmode,"C:TurboC4BGI");
x=getmaxx()/2;
y=getmaxy()/2;
for(i=30;i<200;i++)
{
delay(100);
setcolor(i/10);
arc(x,y,0,180,i-10);
}
getch();
}

===========================================================================

3.) Draw a Smiley

#include
#include
#include
#include

void main()

{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:BGI");
outtextxy(150,10,"This is a program to draw a Smiley Asshole!");
circle(200,200,80);
circle(160,180,8);
circle(240,180,8);
arc(200,230,180,360,20);
line(190,245,210,260);
line(210,245,210,260)
arc(200,260,180,360,9);
line(200,180,195,210);
arc(202,210,190,10,8);
getch();
closegraph();

}

===========================================================================

4.) Draw a Diagonal Line

#include < stdio.h >
#include < conio.h >
#include < graphics.h >

void main()
{
int gdriver=DETECT,gmode=0;
initgraph(&gdriver, &gmode, "c:tcbgi");
line(0,0,getmaxx(),getmaxy());
getch();
closegraph();

}

===========================================================================

5.) Draw an Eclipse

#include
#include

main()
{
int gd = DETECT, gm;

initgraph(&gd, &gm, "C:TCBGI");

ellipse(100, 100, 0, 360, 50, 25);

getch();
closegraph();
return 0;
}

===========================================================================

5.) Draw a Triangle

#include
#include
#include

void main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "c:tcbgi");

line(300, 100, 200, 200);
line(300, 100, 400, 200);
line(200, 200, 400, 200);

getch();
closegraph();
}

There are others as well which are related to Web Development. The posts belonging to Web-development could already be accessed from here. The section is for everything related to ‘code’ and working with code in different languages. HTML could be found there. I would appreciate if the readers leave behind a feedback. Roger out./-

Advertisements

Looking for intellectual opinions. Feedbacks are welcome!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s