42 Replies
The part I don't get is
getRed
, getGreen
, getBlue
Are those methods of the Color class?random.nextInt(256)
is a 1:1 translation of Math.floor(Math.random() * 256)
which makes a number from 0-255.
I'm 99% sure that mix.getXYZ()
gets the red/green/blue in the form of 0-255. The Color
type is irrelevant here.
yeah they should beYup I was typing it out and got this:
I just merged the conditional with the assignments
They are the same
yeah they are
well
not strictly as you have a typo
mix.[2]
but that's pedanticnot anymore 😜
oh and you do need to use math.floor
twice
cuz if you get a colour like red = 5 and mix[0] = 2 then
(5 + 2) / 2 = 3.5
and you want an integer colour
as it turns out Java's division operator on integers automatically floors the result
e.g. in JS 5 / 2 = 2.5
but in Java 5 / 2 = 2
while 5.0 / 2.0 = 2.5
@lukeabby https://codepen.io/arcanist/pen/jOmxvPj
is that a satisfying result?
The colors are a bit muted. I also feel like the top and bottom should be more different
![No description](https://cdn.answeroverflow.com/870778939071684608/unknown.png)
![No description](https://cdn.answeroverflow.com/870779088506343444/unknown.png)
You can't even see a gradient on this one