sugarcube 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ios/sugarcube-color/uicolor.rb +13 -0
- data/lib/version.rb +1 -1
- data/spec/ios/uicolor_spec.rb +37 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d52580e3773a931152ef302be052a43d462bcc0c
|
4
|
+
data.tar.gz: de1452399490a8508da53a2bc56e0dfb3de304cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea2ceb3212c6f2460ac08f8b1491423020fff054df580319aea7bb86256bc44cccc3ef0f0adc1592ffdfd46b17b041416467509d244e98c26c18d83c06a78c5
|
7
|
+
data.tar.gz: 5524449dbaa7e15fe6831ec4252dc8794a516fb5d6710499ca4898309ee9e18990195dc39eedfbf9dc1a985f6db6dfae5f9fadea7bbfdf70780c805a64736ca2
|
@@ -16,6 +16,19 @@ class UIColor
|
|
16
16
|
uicolor(alpha)
|
17
17
|
end
|
18
18
|
|
19
|
+
def darken(amount=0.1)
|
20
|
+
change_brightness -amount
|
21
|
+
end
|
22
|
+
|
23
|
+
def lighten(amount=0.1)
|
24
|
+
change_brightness amount
|
25
|
+
end
|
26
|
+
|
27
|
+
def change_brightness(amount)
|
28
|
+
new_brightness = brightness + amount
|
29
|
+
UIColor.colorWithHue(hue, saturation: saturation, brightness: new_brightness, alpha: alpha)
|
30
|
+
end
|
31
|
+
|
19
32
|
# blends two colors by averaging the RGB and alpha components.
|
20
33
|
# @example
|
21
34
|
# :white.uicolor + :black.uicolor == :gray.uicolor
|
data/lib/version.rb
CHANGED
data/spec/ios/uicolor_spec.rb
CHANGED
@@ -26,12 +26,43 @@ describe "UIColor" do
|
|
26
26
|
'#4dc223'.uicolor(0.5).should == '#4dc223'.uicolor(0.5)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
it "should have r/g/b/hue/sat/brightness attributes" do
|
30
|
+
'#ffffff'.uicolor.red.should == 1
|
31
|
+
'#ffffff'.uicolor.green.should == 1
|
32
|
+
'#ffffff'.uicolor.blue.should == 1
|
33
|
+
'#ffffff'.uicolor.brightness.should == 1
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "should support changing brightness" do
|
37
|
+
# Test by using #hex as brightness will differ e.g. 0.9 vs 0.911182...
|
38
|
+
it "should darken" do
|
39
|
+
'#ffffff'.uicolor.darken(0.1).hex.should == '#e5e5e5'.uicolor.hex
|
40
|
+
end
|
41
|
+
it "should invert darken" do
|
42
|
+
'#ffffff'.uicolor.darken(0.1).lighten(0.1).hex.should == '#ffffff'.uicolor.hex
|
43
|
+
end
|
44
|
+
it "should lighten" do
|
45
|
+
'#e6e6e6'.uicolor.lighten(0.1).hex.should == '#ffffff'.uicolor.hex
|
46
|
+
end
|
47
|
+
it "should invert lighten" do
|
48
|
+
'#e5e5e5'.uicolor.lighten(0.1).darken(0.1).hex.should == '#e5e5e5'.uicolor.hex
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "should support css names" do
|
53
|
+
[
|
54
|
+
:blanchedalmond,
|
55
|
+
:chartreuse,
|
56
|
+
:darkgreen,
|
57
|
+
:deepskyblue,
|
58
|
+
:floralwhite,
|
59
|
+
].each do |name|
|
60
|
+
it "should support #{name}" do
|
61
|
+
name.uicolor.should.be.kind_of(UIColor)
|
62
|
+
name.uicolor(0.5).should.be.kind_of(UIColor)
|
63
|
+
name.uicolor(0.5).alpha.round(1).should == 0.5
|
64
|
+
end
|
65
|
+
end
|
35
66
|
end
|
36
67
|
|
37
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin T.A. Gray
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: |
|
17
17
|
== Description
|