Results 1 to 7 of 7

Math Help - Colors

  1. #1
    Junior Member
    Joined
    May 2007
    Posts
    42

    Colors

    Hello,

    I want to generate 11 basic colors in RGB(8bit and excluding black and white) automatically. Any pre defined algoritham is there for that or any logic.

    Thanks
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member
    Joined
    Apr 2009
    From
    Atlanta, GA
    Posts
    409
    Are you talking about:

    for(i=0; i<11; i++)
    {
    red=(int) 255*Math.rand();
    green=(int) 255*Math.rand();
    blue=(int) 255*Math.rand();
    color[i]= new Color(red, green, blue);
    }

    ???

    What exactly do you mean by "basic" and "automatic"? Can you clarify the problem at hand?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    May 2007
    Posts
    42
    Thanks for your reply.

    Samething only I want. but I can't use rand function. Because it will return different values eachtime. whenever I run that It should always return same colors for each interval(1 means red, 2 means blue like that, this should not vary). for this any pre defined algorithm is there? I want to generate any 11 different colors.

    Thanks
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Senior Member
    Joined
    Apr 2009
    From
    Atlanta, GA
    Posts
    409

    Circle Method

    I understand. Why can't you choose your favorite 11 colors and hard code them?

    Here is an algorithm that will work (in java):

    int n=11;
    int c[]={127,127,127};
    int x[]={85,-85,-85};
    int y[]={-85,85,-85};
    Color color[]= new Color[n];
    int r,g,b;
    double theta;
    for (int i=0; i<n; i++){
    theta=i*360.0/n;
    r=(int)(c[0]+Math.cos(theta)*x[0]+Math.sin(theta)*y[0]);
    g=(int)(c[1]+Math.cos(theta)*x[1]+Math.sin(theta)*y[1]);
    b=(int)(c[2]+Math.cos(theta)*x[2]+Math.sin(theta)*y[2]);
    color[i]= new Color(r,g,b);
    }

    Let me know if this produces your desired result. The only disadvantage is you cannot pick your own colors. Also keep in mind that this requires 14 lines of code, and has to be re-calculated every time the program runs. Even though hard-coding your favorite 11 colors is not as mathematically "pretty," it saves computing time and gives you more control.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    May 2007
    Posts
    42
    Same colors should not repeat Accoring to that logic some colors are repeating and tint colors are also coming. for example first color is green, then lightgreen(means nearest green) should not come in the 11 colors because afterthat I have to do tint of that 11 colors and I want know that algorithm name.

    Thanks
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Senior Member
    Joined
    Apr 2009
    From
    Atlanta, GA
    Posts
    409

    Maximum number of tints

    I see. If by "tint" you mean which color is most prominent, second most prominent, least prominent, then there really are only 6 "tints" corresponding to the possible orders of colors from "darkest" to "lightest." You could add a little bit of variation by assuming certain ones were equal:

    R<G<B R<G=B
    R<B<G R=B<G
    B<R<G B<R=G
    B<G<R B=G<R
    G<B<R G<B=R
    G<R<B G=R<B

    ARE YOU NOT ALLOWED TO HARD CODE THESE?

    int lo=42,md=127,hi=212;
    Color color[]= new Color[11];
    color[0]= new Color(lo,md,hi);
    color[1]= new Color(lo,md,md);
    color[2]= new Color(lo,hi,md);
    color[3]= new Color(lo,lo,md);
    color[4]= new Color(hi,lo,md);
    etc...
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Junior Member
    Joined
    May 2007
    Posts
    42
    If any algorithm is there, I have to use that, Otherwise I can implement any logic. First I want to know any algorithm is there or not for generating 11 different colors using different rgb values.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. [SOLVED] Car colors
    Posted in the Statistics Forum
    Replies: 6
    Last Post: January 27th 2011, 06:35 PM
  2. Colors
    Posted in the Advanced Applied Math Forum
    Replies: 3
    Last Post: March 20th 2009, 06:51 AM
  3. One Spinner 3 Colors
    Posted in the Statistics Forum
    Replies: 2
    Last Post: October 25th 2008, 10:22 PM
  4. colors
    Posted in the Algebra Forum
    Replies: 1
    Last Post: May 3rd 2007, 08:29 AM
  5. Do you know your colors?
    Posted in the Math Challenge Problems Forum
    Replies: 2
    Last Post: December 21st 2006, 09:45 AM

Search Tags


/mathhelpforum @mathhelpforum