This site requires JavaScript, please enable it in your browser!
Greenfoot back
Kartoffelbrot
Kartoffelbrot wrote ...

2013/12/3

RGB is to less

Kartoffelbrot Kartoffelbrot

2013/12/3

#
I have two RGB-Colors, which differ only by 1 in (only!) one of the RGB-values. So there is no RGB-colour between them. Example: Color a = new Color( 100, 255, 0, 255); Color b = new Color( 101, 255, 0, 255); So how can i mix them to get a colour between them? Furthermore I need more than one color between them, the best is as much as possible. Is there another Color class or are there some tricks?
lordhershey lordhershey

2013/12/3

#
Can you even differentiate between these 2 colors? For a case like this you might be wasting time but check this: http://stackoverflow.com/questions/726549/algorithm-for-additive-color-mixing-for-rgb-values , but taking the ceiling of the average for the red component will give you 101
davmac davmac

2013/12/3

#
So how can i mix them to get a colour between them?
why do you think you need to do this?
danpost danpost

2013/12/3

#
There are an infinite number of colors between them; however, they are not displayable due to the limits of programming are concerned, and two colors that close are virtually identical (or undistinguishable) and for programming purposes are not needed. I think what you want is to do something like the SmoothMover class does for movement. That is, use 'double' values to track each color part, adding and subtracting fractional amounts to them, but using their converted 'int' values to update the displayed color.
Kartoffelbrot Kartoffelbrot

2013/12/3

#
@davmac: I need it for my Mandelbrot-Set scenario. I want tthe colours being smooth like in the screenshots in the wikipedia article: http://commons.wikimedia.org/wiki/File:Big_Mandelbrot_set.jpg @ danpost: Yes you are right by thinking what I mean. Actually I am doing it kind of this way so far. I have a ColorSpectrum class, which has the static method for getting every color of the RGB spectrum with a constant alpha of 255. So I have 1530 colours. The parpameter is an integer:
public static Color getColor(int place){
        //code
    }
Replacing the integer only by a double value is useless. Thanks for help so far.
SPower SPower

2013/12/3

#
@Kartoffelbrot Making the color objects more precise won't help: as danpost said you can't see it. And to get smooth colors, you should use the technique called Continuous coloring, which still uses the normal colors but interpolates the colors between 2 values which are far away, not closely :)
davmac davmac

2013/12/3

#
Your monitor can only display 24-bit colour at the most (8 bits Red, Green, Blue). It's unlikely that you'd be able to tell the visual difference between the two colours (a,b) that you describe above.
Kartoffelbrot Kartoffelbrot

2013/12/4

#
Oh ok, thank you all.
You need to login to post a reply.