rcade_colors 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d21ad581309ec030e0493349400ef654b7d9a5ca
4
- data.tar.gz: 7093a8ee0f53e4f446a104ebb31a70fe1f2fd554
3
+ metadata.gz: b02c071ca357fd50a679d4883eb56d41094915ba
4
+ data.tar.gz: 09155f09d2872d1d94c28d32abe712bb6042c1f7
5
5
  SHA512:
6
- metadata.gz: 77df3348ea9d3964df22ebe78cd359d538e4b25dce9046dc16a6aa2bc62eb95f94c664976746699c3fd544d3999318f374b7a3d33b06d0c79becae26b0545003
7
- data.tar.gz: 3a2126aa128f65d62ecf50b6b873f272c9e98022c8b15f82d61c2e1ebd76d82e9e255168c3a50026eb570ab41fb0eba0a220b967f052326dc9c1d375651985f9
6
+ metadata.gz: 68d8ad33f3331ad5d6edc6a277b83611859372a8c171f88687456dbebff5d917755a118fe2575248ea35a93d963648de8158a7f940b64988e9c1bc6224a8dffc
7
+ data.tar.gz: 6526a6c4f12cd7e5efb1f89d828de7d093d23a9d10a6d0e030a65ffa16c4c4ea668a7099f23098f61bff352ed29ae196beeadcd64403a2cf02924b714d6aa4bd
data/lib/rcade_colors.rb CHANGED
@@ -4,8 +4,7 @@ class Gosu::Color
4
4
  # Provides the ability to adjust the opacity (alpha).
5
5
  # The opacity argument should be a float 0.0..1.0
6
6
  def opacity(opacity)
7
- a = alpha * opacity
8
- hex_string = "0x%02x%02x%02x%02x" % [(alpha * opacity), red, green, blue]
7
+ hex_string = "0x%02x%02x%02x%02x" % [(opacity * 255), red, green, blue]
9
8
  self.class.argb(hex_string.to_i(16))
10
9
  end
11
10
  end
data/rcade_colors.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "rcade_colors"
5
- spec.version = "0.0.5"
5
+ spec.version = "0.0.6"
6
6
  spec.authors = ["Andrew Havens"]
7
7
  spec.email = ["email@andrewhavens.com"]
8
8
  spec.description = %q{Provides additional CSS Hex value and opacity support for Gosu.}
@@ -4,49 +4,60 @@ require 'rcade_colors'
4
4
 
5
5
  describe Rcade::Color do
6
6
 
7
- it 'can create black from hex' do
8
- c = Rcade::Color.from_hex('000000')
9
- [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
10
- c = Rcade::Color.from_hex('000')
11
- [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
12
- c = Rcade::Color.from_hex('#000000')
13
- [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
14
- c = Rcade::Color.from_hex('#000')
15
- [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
16
- end
7
+ describe '.from_hex' do
8
+ it 'can create black from hex' do
9
+ c = Rcade::Color.from_hex('000000')
10
+ [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
11
+ c = Rcade::Color.from_hex('000')
12
+ [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
13
+ c = Rcade::Color.from_hex('#000000')
14
+ [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
15
+ c = Rcade::Color.from_hex('#000')
16
+ [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255]
17
+ end
17
18
 
18
- it 'can create white from hex' do
19
- c = Rcade::Color.from_hex('ffffff')
20
- [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
21
- c = Rcade::Color.from_hex('fff')
22
- [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
23
- c = Rcade::Color.from_hex('#ffffff')
24
- [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
25
- c = Rcade::Color.from_hex('#fff')
26
- [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
27
- c = Rcade::Color.from_hex('fFf') # case shouldnt matter
28
- [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
29
- end
19
+ it 'can create white from hex' do
20
+ c = Rcade::Color.from_hex('ffffff')
21
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
22
+ c = Rcade::Color.from_hex('fff')
23
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
24
+ c = Rcade::Color.from_hex('#ffffff')
25
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
26
+ c = Rcade::Color.from_hex('#fff')
27
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
28
+ c = Rcade::Color.from_hex('fFf') # case shouldnt matter
29
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255]
30
+ end
30
31
 
31
- it 'can create red from hex' do
32
- c = Rcade::Color.from_hex('ff0000')
33
- [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
34
- c = Rcade::Color.from_hex('f00')
35
- [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
36
- c = Rcade::Color.from_hex('#ff0000')
37
- [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
38
- c = Rcade::Color.from_hex('#f00')
39
- [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
32
+ it 'can create red from hex' do
33
+ c = Rcade::Color.from_hex('ff0000')
34
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
35
+ c = Rcade::Color.from_hex('f00')
36
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
37
+ c = Rcade::Color.from_hex('#ff0000')
38
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
39
+ c = Rcade::Color.from_hex('#f00')
40
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255]
41
+ end
40
42
  end
41
43
 
42
- it 'can modify opacity' do
43
- c = Rcade::Color.from_hex('#f00').opacity(0)
44
- [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,0]
44
+ describe '#opacity' do
45
+ it 'can modify opacity' do
46
+ c = Rcade::Color.from_hex('#f00').opacity(0)
47
+ [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,0]
48
+
49
+ color = Rcade::Color.from_hex('#f00').opacity(1)
50
+ color.alpha.must_equal(255)
45
51
 
46
- color = Rcade::Color.from_hex('#f00').opacity(1)
47
- color.alpha.must_equal(255)
52
+ color = Rcade::Color.from_hex('#f00').opacity(0.5)
53
+ color.alpha.must_equal(127)
54
+ end
48
55
 
49
- color = Rcade::Color.from_hex('#f00').opacity(0.5)
50
- color.alpha.must_equal(127)
56
+ it 'can modify the opacity of a color that has already been modified' do
57
+ color = Rcade::Color.from_hex('#f00').opacity(0.5)
58
+ color.alpha.must_equal(127)
59
+ color = color.opacity(1.0)
60
+ color.alpha.must_equal(255)
61
+ end
51
62
  end
52
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcade_colors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Havens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-15 00:00:00.000000000 Z
11
+ date: 2013-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu