Color Attributes acting like integers

I'm trying to make an object that will change it's red and green attribute to a random value between 0.2 and 1. but after testing them and looking at the debug screen, their values are either 0 or 1. I used the random function and did not type it in directly (I hear that doesn't work) do you have any idea of what might be the problem? Also, the initial value for the 3 colors before they change is Red=0.5, Green=0.5, and Blue=0 here's a screenshot of what I did in case you need one:

photo ScreenShot2013-04-02at20536PM_zpsad32aaa4.png

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2013
    Change attribute to (random(0,204)/255)+0.2
  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2013
    Or . . . .

    Change attribute to random(51,255)/255
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Or, Change Attribute to random(200,1000)/1000 :-)
  • SocksSocks London, UK.Member Posts: 12,822

    Or, Change Attribute to random(200,1000)/1000 :-)
    Your numbers are less than optimal for an 8bit value, you have been reported to the colour police.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited April 2013

    Or, Change Attribute to random(200,1000)/1000 :-)
    Your numbers are less than optimal for an 8bit value, you have been reported to the colour police.
    The colour police almost smashed the door in... OK, I said, the RGB attributes are real and you get three decimal places, I said, so it's 8 bit all the way; then they said, you tryin' to be funny, son? And I said, no, wouldn't dream off it... cup of tea and a bourbon biscuit? So they said, you try to bribe us again you're really gonna be in for it, then one of them smashed my telly screen with his truncheon, then I said, now look here, that's goin' a bit too far; then they just laughed and backed out of the door, glaring like, saying, we've got our eye on you....
  • SocksSocks London, UK.Member Posts: 12,822
    @gyroscope

    We are watching you and your new fangled maths, with these so called 'decimal places'.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    :o3
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    What you may have gathered through all of the police chatter is that the random() function only works with integers. Since you are working with colors, you need the /255, but otherwise the way to do a random number between 0.2 and 1 is this:

    random(2,10)/10
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited April 2013

    And just for the record, @ADSentertainment , the way shown by tatiang is for 1 decimal place only, two decimal places would be random(20,100)/100 and for three decimal places, as I put earlier. It just depends on how much choice of colour variation you want. And that's no joke.
  • ADSentertainmentADSentertainment Member Posts: 397
    What you may have gathered through all of the police chatter is that the random() function only works with integers. Since you are working with colors, you need the /255, but otherwise the way to do a random number between 0.2 and 1 is this:

    random(2,10)/10
    Ah, ok. thank you. If I may ask though, why does random only work for integers?
  • ADSentertainmentADSentertainment Member Posts: 397
    edited April 2013

    And just for the record, @ADSentertainment , the way shown by tatiang is for 1 decimal place only, two decimal places would be random(20,100)/100 and for three decimal places, as I put earlier. It just depends on how much choice of colour variation you want. And that's no joke.
    Alright, that makes sense.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    My guess is it's just easier to implement and there's less room for user error. Can you imagine if random(0.00,2.00) was allowed and worked for non-integers? Should the program generate integers, hundredths, ...?
  • ADSentertainmentADSentertainment Member Posts: 397
    My guess is it's just easier to implement and there's less room for user error. Can you imagine if random(0.00,2.00) was allowed and worked for non-integers? Should the program generate integers, hundredths, ...?
    What if you were to do it as a fraction? can you do like random (1/5,1)?
  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2013
    What if you were to do it as a fraction? can you do like random (1/5,1)?
    That would always return '1' or '0'
  • ADSentertainmentADSentertainment Member Posts: 397
    What if you were to do it as a fraction? can you do like random (1/5,1)?
    That would always return '1' or '0'
    darn :\
Sign In or Register to comment.