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 +4 -4
- data/lib/rcade_colors.rb +1 -2
- data/rcade_colors.gemspec +1 -1
- data/test/rcade_colors_test.rb +49 -38
- 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: b02c071ca357fd50a679d4883eb56d41094915ba
|
4
|
+
data.tar.gz: 09155f09d2872d1d94c28d32abe712bb6042c1f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
+
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.}
|
data/test/rcade_colors_test.rb
CHANGED
@@ -4,49 +4,60 @@ require 'rcade_colors'
|
|
4
4
|
|
5
5
|
describe Rcade::Color do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
|
52
|
+
color = Rcade::Color.from_hex('#f00').opacity(0.5)
|
53
|
+
color.alpha.must_equal(127)
|
54
|
+
end
|
48
55
|
|
49
|
-
color
|
50
|
-
|
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.
|
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-
|
11
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|