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 +4 -4
- data/lib/falu/palette.rb +20 -5
- data/lib/falu/version.rb +1 -1
- 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: 45629076a1ecd71f5f580fe62e6f503e3bbdad71
|
4
|
+
data.tar.gz: 470d8543f3627d8698f5254da48e542275914cab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fcae3ff34fb7e624d1a3b906e6a99be7ebb4e3dc6f8ac2ed2f4a7b51f421988625c78600865896bda94af25a7513641a5b94cb88c34633a52d30c78c23c5702
|
7
|
+
data.tar.gz: 3fa2eb9f1aa7e4499f9a1073777d16fade254d2d21082514a9411058a7b24a4caea3bfd3abe44de4318b6771169a366d47f36d5825acfc9857240bc40994e83b
|
data/lib/falu/palette.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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).
|
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
|
-
|
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 ||=
|
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={})
|
data/lib/falu/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: canfig
|