summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/color.rb14
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