swatchman 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/swatchman/palette.rb +5 -5
- data/lib/swatchman/swatch.rb +5 -1
- data/lib/swatchman/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123a0d53d09c7a5d82634bdd74163bdfe66458bd2ab55ffeb25619af2fea868f
|
4
|
+
data.tar.gz: 3b3f31d8e91d481dada9e6c2ed685705841525b72a36764675f1c81efc1b231e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d5adf0436186d170d2b666b1e75a1973b91d802dbb7affe03380dcd8fda11307dacf8b63385a456ed98d5d4f37191a57beeefc4d8a018ffa2ad9d39a8939f93
|
7
|
+
data.tar.gz: 4437d61665ceb29e5eb08633b13549a79d70371cc83a788b44e0a12e92a3450c500a47c1135fec32caae5dc046b98ab9618ac85c7780b103710f941a5975d826
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,8 +24,9 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
Swatchman will return 3 swatches by default. Specify the `
|
27
|
+
Swatchman will return 3 swatches by default. Specify the `size` named parameter when calling the `palette` method to adjust the number of swatches returned.
|
28
28
|
|
29
|
+
`swatch` has a method for calculating the percentage which recieves one paramater being the `total` this can be retrieved through `palette.total`.
|
29
30
|
### From a URL
|
30
31
|
|
31
32
|
```ruby
|
data/lib/swatchman/palette.rb
CHANGED
@@ -15,6 +15,10 @@ module Swatchman
|
|
15
15
|
end.reverse.slice(0, size)
|
16
16
|
end
|
17
17
|
|
18
|
+
def total
|
19
|
+
@total ||= histogram_swatches.map(&:frequency).reduce(:+).to_f
|
20
|
+
end
|
21
|
+
|
18
22
|
private
|
19
23
|
|
20
24
|
attr_reader :histogram
|
@@ -26,9 +30,5 @@ module Swatchman
|
|
26
30
|
Swatch.new(color, frequency.to_i)
|
27
31
|
end
|
28
32
|
end
|
29
|
-
|
30
|
-
def total
|
31
|
-
@total ||= histogram_swatches.map(&:frequency).reduce(:+).to_f
|
32
|
-
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
data/lib/swatchman/swatch.rb
CHANGED
data/lib/swatchman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swatchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Hill
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -33,6 +33,7 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- ".gitignore"
|
36
|
+
- ".ruby-version"
|
36
37
|
- ".travis.yml"
|
37
38
|
- CODE_OF_CONDUCT.md
|
38
39
|
- Gemfile
|