Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Graphics with C programming for Different shapes

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-01-2010
Member
 
Join Date: Nov 2009
Posts: 56
Graphics with C programming for Different shapes
  

I want to know about the C programming? What is the graphics in C programming? How can I create graphics for circle,rectangle and Triangle?
How can I build my application in C using graphics?

Reply With Quote
  #2  
Old 12-01-2010
Member
 
Join Date: May 2008
Posts: 2,291
Re: Graphics with C programming for Different shapes

C is a basic purpose language that is developed by Dennis Ritchie at the AT&TBells Laboratories in 1972 for specially compatible with the Unix operating system and specially for designing system software but now a days it is being used by MS-DOS.
It is mother language of the newer programming languages .It was designed to be compiled using a relatively straightforward compiler that execute the code using top to down approach.
C supports a rich set of operators, which are symbols used within an expression and programmer can perform a lot of operation and calculation using variables and many more Like:
1. Basic datatypes and operators
2. Uinon and structure
3. File handling
4. Functions
5. Graphics
6. Pointers
using these provided facility,we can build a strong application

Last edited by Zecho : 12-01-2010 at 09:44 AM.
Reply With Quote
  #3  
Old 12-01-2010
Member
 
Join Date: Apr 2008
Posts: 2,000
Re: Graphics with C programming for Different shapes

Using Graphics in C language
To make a good look of our application,we use the graphics that provides a lot of shapes that are achieved by graphics codes.In a C program you need to initialize the graphics to your computer which is controlled by in-build header file "graphics.h" into the library of C.

Graphics Mode initialization
First of all you need to call the initgraph function which takes the following form:

void initgraph(int far *grdriver, int far *grmode, char far *pathtodriver);
This prototype will set the graphics system using graphics driver from disk(validating a registered driver) .

Take a look of sample program which initialize graphics mode in C Language.

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{

int grdriver = DETECT, grmode, errorcode;


initgraph(&grdriver, &grmode, "");


errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}


line(0, 0, getmaxx(), getmaxy());


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

Last edited by kelfro : 12-01-2010 at 10:51 AM.
Reply With Quote
  #4  
Old 12-01-2010
Member
 
Join Date: May 2008
Posts: 2,007
Re: Graphics with C programming for Different shapes

Creating circle in graphics in C:
The circle command takes three parameters x coordinate ,y coordinate and radius which indicates x coordinate for Vertical axis, y coordinate for Horizontal axis and last one is radius of circle.We can construct it as follows:


#include<graphics.h>
#include<conio.h>
main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
circle(150,150,100);
getch();
closegraph();
}

Last edited by Katty : 12-01-2010 at 10:46 AM.
Reply With Quote
  #5  
Old 12-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,947
Re: Graphics with C programming for Different shapes

Creating Rectangle in C

To create a rectangle in you need to initialize the graphics mode first and use rectangle function to draw a rectangle. This function takes four arguments left, top, right and bottom and every parameters should be in integer. A sample program which creates a rectangle:


#include<graphics.h>
#include<conio.h>
main()
{
int graphd=DETECT,graphm;
initgraph(&graphd,&graphm,"");
rectangle(100,80,100,390);
getch();
closegraph();
}

Last edited by Praetor : 12-01-2010 at 10:49 AM.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Graphics with C programming for Different shapes"
Thread Thread Starter Forum Replies Last Post
Graphics program required in C programming Language ramsun Software Development 3 19-11-2009 11:17 AM
How to cut shapes in Adobe Photoshop? marcman Windows Software 3 01-10-2009 08:53 AM
JetBrains Introduces a New Programming Paradigm With its Meta Programming System JoeFrat Software Development 3 13-12-2008 12:49 PM
How to create shapes in Gimp? Beter 2 Burn Out Customize Desktop 3 02-08-2008 12:47 PM
Graphics & other programming in Turbo C/C++ aadipa Software Development 34 19-03-2004 10:59 PM


All times are GMT +5.5. The time now is 12:27 PM.