falu 0.0.7 → 0.0.8

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: ced00c13089a9e5c749ddd0a593301b5b13f0ccf
4
- data.tar.gz: bda7d2f154fafc88ec2be84e40b55f4f0f914c4c
3
+ metadata.gz: 8b235276bb176363e82d734e4fab0ac1efaa229e
4
+ data.tar.gz: e01a8adc24c2d3043ca00ba5610190100124f1e2
5
5
  SHA512:
6
- metadata.gz: d1c4bfbdd97bce559983d7eed04018f96ca22e3c1118ce8a4a85ff23be3400a57212ecc8d56c10d08a4355adcfa0bdd10c438311e9e9b88d95aaac59ff83a240
7
- data.tar.gz: 476e8e3f7ae7f4a0991858f57b671da9e02982b6baddbebfa8023246e9229b52720ed867114ba3db2998a04684331c4705b8d17667f13558ef8a24a7c2a6b55f
6
+ metadata.gz: ccfc93f0732d4d85d1d41301bb2a8b0778fe46940e120bd144398bd95e4d8942d689dcace96f18a9118ec85568612382a7d0be6543f27d0d2c6c9316a25ae1f0
7
+ data.tar.gz: ab7cf7d35a5d87b2f11ceab4c2d5777f10984bd78720ae6aa3370124fddad4c63f489d7a3f78297d3370b114ca10774acc82c46b0b6bb9c9a19c8883103fab51
@@ -15,6 +15,7 @@ module Falu
15
15
  delegate :width, :height, :path, :run_command, to: :image
16
16
 
17
17
  def initialize(image)
18
+ @raw_image = image
18
19
  @image = image
19
20
  end
20
21
 
@@ -88,6 +89,15 @@ module Falu
88
89
  palette.to_a.to_enum
89
90
  end
90
91
 
92
+ def miro
93
+ colors = Miro::DominantColors.new(@raw_image)
94
+ hex = colors.to_hex
95
+ pct = colors.by_percentage
96
+ hex.each_with_index.map do |clr,idx|
97
+ [clr, pct[idx] * 100]
98
+ end
99
+ end
100
+
91
101
  def scale(scale, filename: nil)
92
102
  filename ||= Tempfile.new(['scaled', '.png']).path
93
103
 
@@ -12,10 +12,10 @@ module Falu
12
12
  end
13
13
  end
14
14
 
15
- delegate :sample, :scale, :size, to: :configuration
15
+ delegate :sample, :scale, :size, :miro, to: :configuration
16
16
 
17
17
  def initialize(image, swatches=nil, **opts)
18
- configuration.configure({sample: nil, scale: 500, size: 10})
18
+ configuration.configure({sample: nil, scale: 500, size: 10, miro: false})
19
19
  super(swatches, **opts)
20
20
  @image = image
21
21
  end
@@ -26,7 +26,11 @@ module Falu
26
26
  end
27
27
 
28
28
  def swatches
29
- @swatches = image.scale(scale).sample(0, 0, size: size, sample: sample).map { |swatch| Falu::Swatch.new(*swatch) } if @swatches.empty?
29
+ if miro
30
+ @swatches = image.miro.map { |swatch| Falu::Swatch.new(*swatch) } if @swatches.empty?
31
+ else
32
+ @swatches = image.scale(scale).sample(0, 0, size: size, sample: sample).map { |swatch| Falu::Swatch.new(*swatch) } if @swatches.empty?
33
+ end
30
34
  @swatches
31
35
  end
32
36
 
@@ -34,7 +38,8 @@ module Falu
34
38
  super(options).merge({
35
39
  sample: sample,
36
40
  scale: scale,
37
- size: size
41
+ size: size,
42
+ miro: miro
38
43
  })
39
44
  end
40
45
  end
@@ -2,7 +2,7 @@ module Falu
2
2
  module Version
3
3
  MAJOR = '0'
4
4
  MINOR = '0'
5
- PATCH = '7'
5
+ PATCH = '8'
6
6
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
 
8
8
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-04 00:00:00.000000000 Z
11
+ date: 2017-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: canfig
@@ -120,10 +120,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.4.8
123
+ rubygems_version: 2.6.13
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Extract color swatches from images with imagemagick
127
127
  test_files:
128
128
  - spec/spec_helper.rb
129
- has_rdoc: