Results 1 to 4 of 4

Thread: How make different types of circle in turbo c

  1. #1
    Join Date
    Dec 2009
    Posts
    40

    How make different types of circle in turbo c

    I am a novice user in C graphics. I have just started to learn graphics in C with the basic shapes. But I am not getting the basic shapes correct such as circle, rectangle, ellipse, line and polygon. If I am just typing the code from the book, circle is coming on the screen, but I am not getting the syntax which they use in the programming language. Learning graphics in this way will not help in future. So any body give the coding with complete explanation of syntax they are using.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How make different types of circle in turbo c

    This is the basic circle with explanation of syntax
    #include<graphics.h>
    #include<conio.h>

    void main()
    {
    int gd=DETECT, gm;

    initgraph(&gd, &gm, "c:\\turboc3\\bgi " );
    circle(200,100,150);

    getch();
    closegraph


    Explanation
    InitGraph:
    This syntax initializes the graphics system.
    closegraph()
    This function switches the screen from graphic mode to text mode
    circle(200,100,150)
    This represent the x co ordinate, y co ordinate and radius.

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

    Re: How make different types of circle in turbo c

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

    void main()
    {
    int gd=DETECT, gm;
    int poly[12]={350,450, 350,410, 430,400, 350,350, 300,430, 350,450 };
    initgraph(&gd, &gm, "");

    circle(100,100,50);
    outtextxy(75,170, "Circle");
    rectangle(200,50,350,150);
    outtextxy(240, 170, "Rectangle");
    ellipse(500, 100,0,360, 100,50);
    outtextxy(480, 170, "Ellipse");
    line(100,250,540,250);
    outtextxy(300,260,"Line");

    sector(150, 400, 30, 300, 100,50);
    outtextxy(120, 460, "Sector");
    drawpoly(6, poly);
    outtextxy(340, 460, "Polygon");
    getch();
    closegraph();
    }


    Above code will give the idea of basic shapes like circle, rectangle, polygon, ellipse, filled sectors.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: How make different types of circle in turbo c

    BLACK: 0 BLUE: 1 GREEN: 2 CYAN: 3
    RED: 4 MAGENTA: 5 BROWN: 6 LIGHTGRAY: 7
    DARKGRAY: 8 LIGHTBLUE: 9 LIGHTGREEN: 10 LIGHTCYAN: 11
    LIGHTRED: 12 LIGHTMAGENTA: 13 YELLOW: 14 WHITE: 15

    The above figure / numbers will give you the idea of colors you want to set for your graphics.
    #include "graphics.h"
    #include "conio.h"
    #include "stdlib.h"

    void main()
    {
    int gd,gm;
    gd=DETECT;

    initgraph(&gd, &gm, "");
    setcolor(3);
    setfillstyle(SOLID_FILL,RED);
    bar(50, 50, 590, 430);

    setfillstyle(1, 14);
    bar(100, 100, 540, 380);

    while(!kbhit())
    {
    putpixel(random(439)+101, random(279)+101,random(16));
    setcolor(random(16));
    circle(320,240,random(100));
    }
    getch();
    closegraph();
    }

    This code will create different colors of shape until you press enter key.

Similar Threads

  1. Cityville : How to make a circle road
    By lUMINOUS in forum Video Games
    Replies: 4
    Last Post: 08-02-2011, 11:15 AM
  2. micromax Q3 Vs Fly Circle
    By Truster in forum Portable Devices
    Replies: 10
    Last Post: 27-03-2010, 08:22 AM
  3. Different types Types CCFL's
    By Zipp in forum Overclocking & Computer Modification
    Replies: 3
    Last Post: 29-10-2009, 09:11 AM
  4. How to draw a circle using TI 89
    By Bilal in forum Windows Software
    Replies: 3
    Last Post: 20-06-2009, 11:55 AM
  5. Installing different types of RAM will make any difference?
    By Ackley in forum Motherboard Processor & RAM
    Replies: 3
    Last Post: 23-12-2008, 03:23 PM

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,711,653,419.33997 seconds with 17 queries