falu 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4df7374b394281ccf58ca3834914be2341b12e6
4
- data.tar.gz: ae16e01cf378501cd2d36bb7092b6abcb798e27c
3
+ metadata.gz: 45629076a1ecd71f5f580fe62e6f503e3bbdad71
4
+ data.tar.gz: 470d8543f3627d8698f5254da48e542275914cab
5
5
  SHA512:
6
- metadata.gz: feaf26e05189fd0db64511826450a55dbf55f8ad4bc69de20e483e332a3e495d1226bf7ab91fa37c606ccd835b873f379e1111cef3c733b303dacd6c59c86094
7
- data.tar.gz: 4191f7a9fbe5650d25e4ef193e79bccbe9b584306b9c5c315a9316c2f7930e24152dd27cb381d0675a861041a42a32ff4178fb0057ba91c0487338423b50fa30
6
+ metadata.gz: 8fcae3ff34fb7e624d1a3b906e6a99be7ebb4e3dc6f8ac2ed2f4a7b51f421988625c78600865896bda94af25a7513641a5b94cb88c34633a52d30c78c23c5702
7
+ data.tar.gz: 3fa2eb9f1aa7e4499f9a1073777d16fade254d2d21082514a9411058a7b24a4caea3bfd3abe44de4318b6771169a366d47f36d5825acfc9857240bc40994e83b
@@ -110,7 +110,11 @@ module Falu
110
110
 
111
111
  def primary=(pri)
112
112
  # TODO check that the color exists in the palette
113
- @primary = pri
113
+ if pri.nil?
114
+ @primary = pri
115
+ else
116
+ @primary = pri.is_a?(Falu::Swatch) ? pri : Falu::Swatch.new(*pri)
117
+ end
114
118
  end
115
119
 
116
120
  def primary
@@ -119,22 +123,33 @@ module Falu
119
123
 
120
124
  def secondary=(sec)
121
125
  # TODO check that the color exists in the palette
122
- @secondary = sec
126
+ if sec.nil?
127
+ @secondary = sec
128
+ else
129
+ @secondary = sec.is_a?(Falu::Swatch) ? sec : Falu::Swatch.new(*sec)
130
+ end
123
131
  end
124
132
 
125
133
  def secondary
126
134
  @secondary ||= begin
127
- dominant(3).last(2).sort_by { |swtch| (swtch.color.rgb.colors.sum - primary.color.rgb.colors.sum).abs }.last
135
+ dominant(3).sort_by { |swtch| (swtch.color.hsl.lightness - primary.color.hsl.lightness).abs }.last
128
136
  end
129
137
  end
130
138
 
131
139
  def accent=(acc)
132
140
  # TODO check that the color exists in the palette
133
- @accent = acc
141
+ if acc.nil?
142
+ @accent = acc
143
+ else
144
+ @accent = acc.is_a?(Falu::Swatch) ? acc : Falu::Swatch.new(*acc)
145
+ end
134
146
  end
135
147
 
136
148
  def accent
137
- @accent ||= dominant(3).find { |swtch| ![primary.color.to_s, secondary.color.to_s].include?(swtch.color.to_s) }
149
+ @accent ||= begin
150
+ #dominant(5).select { |swtch| ![primary.color.to_s, secondary.color.to_s].include?(swtch.color.to_s) }.sort_by { |swtch| (swtch.color.hsl.lightness - primary.color.hsl.lightness).abs + (swtch.color.hsl.lightness - secondary.color.hsl.lightness).abs }.last
151
+ dominant(3).find { |swtch| ![primary.color.to_s, secondary.color.to_s].include?(swtch.color.to_s) }
152
+ end
138
153
  end
139
154
 
140
155
  def as_json(options={})
@@ -2,7 +2,7 @@ module Falu
2
2
  module Version
3
3
  MAJOR = '0'
4
4
  MINOR = '0'
5
- PATCH = '4'
5
+ PATCH = '5'
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.4
4
+ version: 0.0.5
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-01 00:00:00.000000000 Z
11
+ date: 2016-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: canfig