chroma 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -4
- data/CHANGELOG.md +12 -0
- data/README.md +9 -0
- data/chroma.gemspec +3 -3
- data/lib/chroma/color/modifiers.rb +13 -0
- data/lib/chroma/version.rb +1 -1
- data/spec/color/modifiers_spec.rb +9 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e29b2a8044d194fea6901e8f3a2cee1ac1e02c7c
|
4
|
+
data.tar.gz: bcb8094e0d1d8362c5475da871bfd384f9263d52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 539daf8edbb40d84276b958cd3866f52351d2e66e8a23be3e15413edf5e9c6b1fa6afd6dbf6fcda6240e2c4d78eb7b063f5cb89db19fdafcf1c38a4c64ddcc66
|
7
|
+
data.tar.gz: 62e2097fa34e8597fbe84ded140b346d73687afa62de0f543942e68d1dfcced4eb2c3d115349cedff09633cfdc4784297e825ef6d7497a460bc87ebcde0324a9
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v0.2.0
|
2
|
+
|
3
|
+
### NEW `.opacity` Method
|
4
|
+
|
5
|
+
Added an `.opacity` method to set the opacity of a color. (credit [@matildasmeds](https://github.com/matildasmeds))
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
'red'.paint.opacity(0.3).to_rgb #=> 'rgba(255, 0, 0, 0.3)'
|
9
|
+
```
|
10
|
+
|
11
|
+
---
|
12
|
+
|
1
13
|
## v0.1.0 - 2016-05-26
|
2
14
|
|
3
15
|
### Dynamic Custom Palettes
|
data/README.md
CHANGED
@@ -126,6 +126,15 @@ Convert the color to grayscale.
|
|
126
126
|
'red'.paint.greyscale #=> #808080
|
127
127
|
```
|
128
128
|
|
129
|
+
#### Opacity
|
130
|
+
|
131
|
+
Set the opacity of the color to a given amount.
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
'red'.paint.opacity(0.3) #=> #ff0000
|
135
|
+
'red'.paint.opacity(0.3).to_rgb #=> 'rgba(255, 0, 0, 0.3)'
|
136
|
+
```
|
137
|
+
|
129
138
|
#### Spin
|
130
139
|
|
131
140
|
Spin a given amount in degrees around the hue wheel.
|
data/chroma.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
22
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.6.0'
|
24
24
|
end
|
@@ -90,6 +90,19 @@ module Chroma
|
|
90
90
|
|
91
91
|
alias_method :greyscale, :grayscale
|
92
92
|
|
93
|
+
# Sets color opacity to the given 'amount'.
|
94
|
+
#
|
95
|
+
# @example
|
96
|
+
# 'red'.paint.opacity(0.5) #=> #ff0000
|
97
|
+
# 'red'.paint.opacity(0.5).to_rgb #=> 'rgba(255, 0, 0, 0.5)'
|
98
|
+
#
|
99
|
+
# @param amount [Fixnum]
|
100
|
+
# @return [Color]
|
101
|
+
def opacity(amount)
|
102
|
+
rgb = @rgb.to_a[0..2] + [amount]
|
103
|
+
self.class.new(ColorModes::Rgb.new(*rgb), @format)
|
104
|
+
end
|
105
|
+
|
93
106
|
# Spins around the hue color wheel by `amount` in degrees.
|
94
107
|
#
|
95
108
|
# @example
|
data/lib/chroma/version.rb
CHANGED
@@ -79,6 +79,15 @@ describe Chroma::Color do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
describe '#opacity' do
|
83
|
+
it 'sets color opacity to supplied amount' do
|
84
|
+
green_a = 'rgba(0, 128, 0, 0.5)'
|
85
|
+
expect(green_a.paint.opacity(1)).to eq 'rgba(0, 128, 0, 1)'.paint
|
86
|
+
expect('green'.paint.opacity(0)).to eq 'rgba(0, 128, 0, 0)'.paint
|
87
|
+
expect(red.opacity(0.3)).to eq 'rgba(100%, 0%, 0%, 0.3)'.paint
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
82
91
|
describe '#spin' do
|
83
92
|
it 'generates the correct color' do
|
84
93
|
expect(red.spin(60)).to eq yellow
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chroma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Fairbank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.15'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.6.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
54
|
+
version: 3.6.0
|
55
55
|
description: Chroma is a color manipulation and palette generation gem.
|
56
56
|
email:
|
57
57
|
- elpapapollo@gmail.com
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.6.11
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Color manipulation and palette generation.
|