sugarcube 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e49be086f1fb48856f9d9d13851d654fbb9d083
4
- data.tar.gz: 189da112fdb2910946a0a08ecd7c2b2da28c6102
3
+ metadata.gz: d52580e3773a931152ef302be052a43d462bcc0c
4
+ data.tar.gz: de1452399490a8508da53a2bc56e0dfb3de304cc
5
5
  SHA512:
6
- metadata.gz: 6d1d2ba229696026bcbd95b86f6981686e8bcc50a85daef2e857d4dfff9b7a37e15b23387abfc42f891e9032b38b9a9cc83335140bf8b738eaa63b34795abec6
7
- data.tar.gz: c1765db065d6d8c9f3d8bf7f7907fdbbc64d85d98d432469e1388d3a136067b316848d43f6add1ab21fbd4e3424742d166b17be77ba3a88a600f34a23e19bfdb
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
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '3.0.4'
2
+ Version = '3.0.5'
3
3
  end
@@ -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 support css names" do
30
- :blanchedalmond.uicolor.should == :blanchedalmond.uicolor
31
- :chartreuse.uicolor.should == :chartreuse.uicolor
32
- :darkgreen.uicolor.should == :darkgreen.uicolor
33
- :deepskyblue.uicolor.should == :deepskyblue.uicolor
34
- :floralwhite.uicolor(0.5).should == :floralwhite.uicolor(0.5)
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
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: 2014-12-23 00:00:00.000000000 Z
14
+ date: 2015-01-08 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: |
17
17
  == Description