Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Resolution of a float for a color vector

    Help
    2
    3
    133
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Bl4ckM4ch1n3 last edited by

      Hi Folks!

      If I got it correctly a color in F4NS is represented by a vector with 4 values (r,g,b,a) and every value is ranging from 0 to 1, right? So what's the supported resolution for this values? Does it even take 0.0039215686274509803921568627451 (1/255)?
      Of course this is just a pretty extreme example.

      Thanks in advance!

      N 1 Reply Last reply Reply Quote 0
      • N
        Nisse5 F @Bl4ckM4ch1n3 last edited by Nisse5

        @Bl4ckM4ch1n3 It doesn't matter much to store 1/255 in this context, since there are are 256 steps in each 8-bit rgba value.

        EDIT - it seems like it has enough accuracy to store 1/256 accurately:

        a = 1/256
        print (a, "\n")
        a += 0.00000025
        a += 0.00000025
        a += 0.00000025
        a += 0.00000025
        print (a, "\n")
        

        Gives this result:
        0.003906
        0.003907

        B 1 Reply Last reply Reply Quote 2
        • B
          Bl4ckM4ch1n3 @Nisse5 last edited by

          @Nisse5 said in Resolution of a float for a color vector:

          It doesn't matter much to store 1/255 in this context, since there are are 256 steps in each 8-bit rgba value

          Of course, I'm such an Idiot :facepalm:
          That happens when you're coding in a hurry! lol

          I assume F4NS will cut floats after the sixth digit after "0.", so I'll cut my generated values after the sixth digit aswell.

          Thank you very much!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post