By all means of logic the screen should turn red after 60 frames, but it doesn’t. This is super weird, because the code for the text fill works just fine. So it seems like the structure fill(color(…)) stops working if you include a ternary operand or something? It’s also broken for other similar functions, such as background().
I think I understand what is happening. random(255) gives a float, while color(255,0,0) gives an int. The thing is that Processing’s color type is actually an int - for proof, compile and then go to the source/thing.java file inside any of the compiled folders, and see that all color variable declarations turn into int.
Anyways, I think that the ternary operator doesn’t want to give 2 different types of output based on the condition, so it just converts all to float - then, fill() tries to understand float(color(255,0,0)), and interprets it as black.
In other words, use round(random(255)) instead so the result of that ternary operator is always int.
True… At that rate, you could also use floor(random(256))…
That is until it rolls exactly 256.000 and you are left wondering what in the world has just happened! :o
So, min(floor(random(256)),255) seems to be the best way around for doing this? :v
But that makes it unfair to numbers, as, for example, it can be any number including and between 3 and 4, but it can’t be any number including and between 255 and 256! So, 255 gets whatever-is-floating-point-error-at-that-point less chance ! ! !