Random Function and Decimal values
I'm trying to have random colors assigned to an object, but I'm finding that's not possible due to the Random function not accepting decimal values and placing random(0,1) only chooses 0 or 1. This wouldn't be an issue if you could simply place an integer value for the Red, Green, and Blue values for the color of an object, instead we're left with equating the value you want for each RGB value as a decimal.
Anyway, my point being.. can anyone prove me wrong that the Random function does in fact accept decimal values and I'm just doing something wrong?
Anyway, my point being.. can anyone prove me wrong that the Random function does in fact accept decimal values and I'm just doing something wrong?
Comments
Change Attribute self.color.Red to random(0,10)/10
@RacetotheMoon
Hi, the Random expression doesn't cater for decimal values; positive integer values only.
So for a solution of a generated random decimal, I suggest something like the following:
(it's probably more watertight to change a real attribute and then use that as the chosen random value) In this example, it'll be for three decimal places:
Change Attribute RandColR to Random(111,999)/1000
Change Attribute self.Color.Red to RandColR
Each colour channel is 8bit, the calculation should be: Change Attribute self.color.Red to random(0,255)/255
So @tatiang is correct in his example to generate in one decimal place, (albeit a limited amount of colours); mine is as close as you can get with three decimal places (actually, I've just thought, a bit closer at the zero end: Random(100,999)/1000 )
Your new method loses the 'bottom' 10% of all colours as well as pure white at the 'top' (1,1,1).
Random(0,255)/255 will give you all 256 colours (8bit) for each channel (or 16,777,216 / 24bits) when applied to all three channels.
Hey @Socks, I see what you mean now... :-) I will flay my back immediately with a horsehair whip! Spot on, and worth remembering, thanks.
Here's the maths in action:
http://www.mediafire.com/?bo8835830d9oy67
Hi @Socks that is Wow indeed! Thanks, I'm much impressed with that! :-)
Takes you a bit more into the mid 1970s. : )
Like this: http://www.mediafire.com/?wmz323k94kr9z4d