Results 1 to 4 of 4

Thread: rainbow spectrum -> RGB?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    east norwalk, ct, usa
    Posts
    184

    rainbow spectrum -> RGB?

    i'm trying to write a function that takes a value from 0 to 1 (0 representing that i want red, 1 that i want violet. you know roygbiv) and sets glColor3f() accordingly to give me those colors. so far, i've tried (unsuccessfully):

    void PhysimGLView::setCurrentColor(GLfloat r)
    {
    if ( r < 0.50 )
    {
    //glColor3f(1.0, 0.0, 0.0);
    glColor3f( ( 0.50 - r )/0.50, r/0.50, 0.00 );
    }
    else
    {
    if ( r >= 0.50 && r < 0.501 )
    {
    glColor3f(0.0, 1.0, 0.0);
    }
    else
    {
    glColor3f( 0.00, ( 0.50 - (r - 0.50) )/0.50, (r - 0.50) /0.50 );
    }
    }

    }

    any ideas?

    thanks.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    east norwalk, ct, usa
    Posts
    184

    Re: rainbow spectrum -> RGB?

    ouch. sorry about the formatting. i'll use spaces next time instead of tabs.

    j

  3. #3
    Member Newbie
    Join Date
    Apr 2000
    Posts
    44

    Re: rainbow spectrum -> RGB?

    If i recall nehe had some rainbow stuff in his partice engine, tutorial 19 or something.

    check this
    hope it helps

    -Thr33d


    [This message has been edited by Thr33d (edited 06-24-2000).]

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    east norwalk, ct, usa
    Posts
    184

    Re: rainbow spectrum -> RGB?

    thanks thr33d,

    that tutorial had some discreet color values for the colors of the rainbow:

    {
    {1.0f,0.5f,0.5f},{1.0f,0.75f,0.5f},{1.0f,1.0f,0.5f },{0.75f,1.0f,0.5f},
    {0.5f,1.0f,0.5f},{0.5f,1.0f,0.75f},{0.5f,1.0f,1.0f },{0.5f,0.75f,1.0f},
    {0.5f,0.5f,1.0f},{0.75f,0.5f,1.0f},{1.0f,0.5f,1.0f },{1.0f,0.5f,0.75f}
    };

    looks like a good place to start.

Similar Threads

  1. Replies: 13
    Last Post: 03-23-2018, 10:15 AM
  2. Rainbow color band and color palettes in OpenGL?
    By rakeshthp in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 01-15-2013, 01:57 AM
  3. How to generate rainbow colors in OpenGl?
    By Fanghui Chen in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 05-23-2001, 07:37 AM
  4. How to genurate rainbow colors on OpenGl?
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-21-2001, 01:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean