Rainbow

This is a discussion on Rainbow within the C Programming forums, part of the General Programming Boards category; What would be the basic of drawing a rainbow in c. I don't mean the colors but the shape....

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    1

    Rainbow

    What would be the basic of drawing a rainbow in c. I don't mean the colors but the shape.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by ram4nd View Post
    What would be the basic of drawing a rainbow in c. I don't mean the colors but the shape.
    I notice you mention x11, so you probably don't want some ascii art

    You have to use either the X library itself, or an API build onto it such as openGL, then a little trigonometry.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Draw a circle (I don't know how yet) of thickness x and radius r. Then draw another circle around it with the same center and thickness, but with r += x.

    PS: This just works in theory. I don't know much about x11.

  4. #4
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by ram4nd View Post
    What would be the basic of drawing a rainbow in c. I don't mean the colors but the shape.
    You can draw several (or 7. i forgot how a rainbow looks like) concentric semi circles and fill them with the desired colors. There are library functions in TC for drawing a circle and filling any object with colors in the header <graphics.h>. I don't know about other IDEs.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by BEN10 View Post
    There are library functions in TC for drawing a circle and filling any object with colors in the header <graphics.h>. I don't know about other IDEs.
    X11 is *nix. AFAIK there is no equivalent of a general purpose simple 2D graphics library (although some can surely be found). You either use X itself (I have no idea how hard that is but methinks it not easy) or go for the whole hog (unlit, untextured 2D stuff in openGL w/ "glut" is fairly simple, but as with any complex API you have to spend some hours coming to terms with it; there is no simple "draw_curve()" command you can just inject into a program).

    As an added bonus, starting with openGL will get you that much closer to distracting the tish out of the mentally infirm -- I understand the gloves come off tomorrow...
    Last edited by MK27; 05-09-2009 at 09:27 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by MK27 View Post
    X11 is *nix. AFAIK there is no equivalent of a general purpose simple 2D graphics library (although some can surely be found). You either use X itself (I have no idea how hard that is but methinks it not easy) or go for the whole hog (unlit, untextured 2D stuff in openGL w/ "glut" is fairly simple, but as with any complex API you have to spend some hours coming to terms with it; there is no simple "draw_curve()" command you can just inject into a program).

    As an added bonus, starting with openGL will get you that much closer to distracting the tish out of the mentally infirm -- I understand the gloves come off tomorrow...
    I dont know what is X11 or X(I haven't heard of it before) but i have made several animating graphics in TC using <graphichs.h>. That's why i think it is also possible to make rainbow in it.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  7. #7
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    where was X11 mentioned?
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. my code is not working
    By turbot in forum C Programming
    Replies: 3
    Last Post: 01-28-2009, 04:23 AM
  2. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  3. What can I do?
    By Unregistered in forum C++ Programming
    Replies: 27
    Last Post: 07-16-2002, 11:44 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21