mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-01-12 17:52:17 +08:00
Adds ability to pass HSVA color params directly
This commit is contained in:
@@ -13,6 +13,12 @@ module RubyMotionQuery
|
||||
b = param[:blue] || param[:b]
|
||||
a = param[:alpha] || param[:a]
|
||||
Color.new_from_rgba(r, g, b, a)
|
||||
elsif (param.keys - [:h, :s, :b, :a, :hue, :saturation, :brightness, :alpha]).empty?
|
||||
h = param[:hue] || param[:h]
|
||||
s = param[:saturation] || param[:s]
|
||||
b = param[:brightness] || param[:b]
|
||||
a = param[:alpha] || param[:a]
|
||||
Color.from_hsva(h, s, b, a)
|
||||
else
|
||||
color = Color.new_from_hex(param[:x] || param[:hex])
|
||||
if alpha = param[:a] || param[:alpha]
|
||||
|
||||
@@ -171,6 +171,9 @@ describe 'color' do
|
||||
@rmq.color(red: 10, green: 10, blue: 10, alpha: 1).should == UIColor.colorWithRed(10/255.0, green: 10/255.0, blue: 10/255.0, alpha: 1)
|
||||
end
|
||||
|
||||
#TODO HSL(A)
|
||||
it 'should allow hsva params in a hash' do
|
||||
@rmq.color(h: 4, s: 3, b: 2, a: 1).should == UIColor.alloc.initWithHue(4, saturation: 3, brightness: 2, alpha: 1)
|
||||
@rmq.color(hue: 4, saturation: 3, brightness: 2, alpha: 1).should == UIColor.alloc.initWithHue(4, saturation: 3, brightness: 2, alpha: 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user