diff options
| author | kamishetty sreeja <[email protected]> | 2016-04-10 17:04:39 +0530 |
|---|---|---|
| committer | kamishetty sreeja <[email protected]> | 2016-04-10 17:04:39 +0530 |
| commit | 56d5bed2650e2a448e58427e2967856ec39ada3e (patch) | |
| tree | cc0f8ef0de66386060ba6854fee94e2112af5625 | |
| parent | c0db462af1ffba389c865efefd5f0344879387ba (diff) | |
| download | ruby2d-56d5bed2650e2a448e58427e2967856ec39ada3e.tar.gz ruby2d-56d5bed2650e2a448e58427e2967856ec39ada3e.zip | |
Implemented rgb hex to float conversion
| -rw-r--r-- | lib/ruby2d/color.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/ruby2d/color.rb b/lib/ruby2d/color.rb index c7bb72d..2768086 100644 --- a/lib/ruby2d/color.rb +++ b/lib/ruby2d/color.rb @@ -67,6 +67,20 @@ module Ruby2D end return b end + #convert from "#FFF000" to Float (0.0..1.0) + def hex_to_f(a) + c=[] + b=a.delete("#") + n=(b.length) + #n1=n/3 + j=0 + for i in (0..n-1).step(n/3) + c[j]=Integer("0x".concat(b[i,n/3])) + j=j+1 + end + f = to_f(c) + return f + end end end |
