Results 1 to 4 of 4

Thread: Simple Graphics program code for "C"

  1. #1
    Join Date
    Nov 2009
    Posts
    56

    Simple Graphics program code for "C"

    Hi All,

    I have understood the basic "C" programming. I have no problem to code the simple C program. But I think the coding of the "C" graphics program is quit difficult.

    If anyone has Simple Graphics program code for "C", then please share with me.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Simple Graphics program code for "C"

    Hi,

    I don't think that it's very complicated to write the C graphics program. Please review below simple graphics program which is written in C:

    Code:

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

    void main()
    {

    int GraphDriverDEmo = graphmd, DETECT, ;

    initgraph(&GraphDriverDemo, &graphmd, "..\\bgi");

    circle(260, 150, 30);

    getch();

    Closegraph();

    }

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Simple Graphics program code for "C"

    Hi friend,

    Below program will illustrate you the simple graphics animation program. The code comprises the graphics of the Rectangle, Line and the Circle. When you will run the below program you will get some movable objects:

    #include<string.h>
    #include<conio.h>
    #include<graphics.h>
    #include<iostream.h>

    void main()
    {
    int a,b;
    int gd1= DETECT,g;
    initgraph(&gd1,&g," ");

    line(0,280,674,260);

    for(int x=10;x<=634;x++)
    {

    line(280+x,250,150+x,250);
    line(330+x,100,280+x,160);


    circle(170+x,175,20);

    rectangle(220+x,250,160+x,170);

    delay(20);

    }

    for( x=444;x>=0;x--)
    {

    line(230-x,140,130-x,160);
    circle(170+x,175,20);
    delay(20);
    }
    getch();
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Simple Graphics program code for "C"

    Hello,

    If you have successfully cleared the looping as well as the condition checking program of the C programming then definitely you won't get any barrier in writing simple C graphics code.
    If you want to code simple animation in the program ,then you will need to use the loop concepts. and to display different shapes with some time delay ,for this you will have to use the "delay(x)" Function. Here the the value of the "x" represent the amount of time delay you want to apply in the program.

    I hope this this may works for you...

Similar Threads

  1. Replies: 6
    Last Post: 19-08-2011, 11:02 PM
  2. Replies: 4
    Last Post: 12-02-2011, 07:10 AM
  3. Replies: 5
    Last Post: 16-01-2011, 07:26 PM
  4. Replies: 1
    Last Post: 01-05-2009, 02:57 AM
  5. XP Home SP2 OEM "Use Simple File Sharing" is not available
    By hariharan_00 in forum Windows Security
    Replies: 3
    Last Post: 20-07-2008, 05:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,048,054.40051 seconds with 16 queries