diff options
| author | Tom Black <[email protected]> | 2016-07-16 16:12:14 -0500 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2016-07-16 16:12:14 -0500 |
| commit | ae2f7d7015d26c12b4b7612a6c6c5703c58c5c57 (patch) | |
| tree | 993364f5bb1535fc02b27e41aa8731c4cd42a052 | |
| parent | 0397b5aedfd9e0e51c27437a0743d4f59b32008e (diff) | |
| parent | 94fc1f516b2f1c2624b5dc2d1cbaf0cbfe8e4796 (diff) | |
| download | ruby2d-ae2f7d7015d26c12b4b7612a6c6c5703c58c5c57.tar.gz ruby2d-ae2f7d7015d26c12b4b7612a6c6c5703c58c5c57.zip | |
Merge remote-tracking branch 'origin/master'
| -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 |
