tinct 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinct.rb +22 -8
  3. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fca6977fef6bdfd22b20e0e608f040c9d9e7ca24206a4b272f5c9bba8095207
4
- data.tar.gz: 2da16913a8af3fcad8584285fdf739d4e12462983a48b7729e92ca34d61198d2
3
+ metadata.gz: 55cf5c4d5f19eeee98f269b9c9b433ee451290935dc892993d9fc4bb66889145
4
+ data.tar.gz: 070f293b25b1d648de1f5bd360d80cdd4d14f851339ce8165184e1fc641d2310
5
5
  SHA512:
6
- metadata.gz: 3446fff8655d035c6a63de18d1ed1c11ede475fdab1e8b8d60cef44ee50ff60f4e0e33bbd4988b4e9c47da128b418e86e0e16e0c4428b344bfd345d13791a27d
7
- data.tar.gz: c7846a3aa20c82fade120750899c23da02176ffbd0686cd145c794a804fc18c97b084ff904a1feedc10b69a8e73cc17a9080562f7d5978105331d685116e8f57
6
+ metadata.gz: 8e29b9519253d102533ef91e472762bdc46bc4603d40987e98d051a7cad0b1d2c05cdb6c8719eb4e2045018897611ae3b9ab4631f76772ad6e516097e46359b1
7
+ data.tar.gz: 610bfa421d080c39ee905d6c6353b6a74a5f6a78bad4a5af564559a74589422ef68dde4e67b17e81d301d91af4edabc14ac2f013f43b91bd6f6aff53a4fad43d
@@ -1,5 +1,5 @@
1
1
  class Tinct
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
 
4
4
  attr_accessor :red, :green, :blue, :alpha
5
5
 
@@ -21,20 +21,23 @@ class Tinct
21
21
  end
22
22
 
23
23
  def hue=(hue)
24
- self.hue = Tinct.hsl(hue, saturation, lightness, alpha).hue
24
+ copy(Tinct.hsl(hue, saturation, lightness, alpha))
25
+ hue
25
26
  end
26
27
 
27
28
  def saturation
28
29
  max = [@red, @green, @blue].max
29
30
  min = [@red, @green, @blue].min
30
31
  delta = max - min
31
- l = (max + min / 2)
32
- return 0 if max == min
33
- l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min)
32
+ total = max + min
33
+ l = total / 2
34
+ return 0 if delta == 0
35
+ l < 0.5 ? delta / total : delta / (2 - max - min)
34
36
  end
35
37
 
36
38
  def saturation=(saturation)
37
- self.saturation = Tinct.hsl(hue, saturation, lightness, alpha).saturation
39
+ copy(Tinct.hsl(hue, saturation, lightness, alpha))
40
+ saturation
38
41
  end
39
42
 
40
43
  def lightness
@@ -44,7 +47,8 @@ class Tinct
44
47
  end
45
48
 
46
49
  def lightness=(lightness)
47
- self.lightness = Tinct.hsl(hue, saturation, lightness, alpha).lightness
50
+ copy(Tinct.hsl(hue, saturation, lightness, alpha))
51
+ lightness
48
52
  end
49
53
 
50
54
  def value
@@ -52,7 +56,8 @@ class Tinct
52
56
  end
53
57
 
54
58
  def value=(value)
55
- self.value = Tinct.hsv(hue, saturation, value, alpha).value
59
+ copy(Tinct.hsv(hue, saturation, value, alpha))
60
+ value
56
61
  end
57
62
 
58
63
  def brightness
@@ -252,4 +257,13 @@ class Tinct
252
257
  self.key = percentage * key
253
258
  self
254
259
  end
260
+
261
+ private
262
+
263
+ def copy(other)
264
+ self.red = other.red
265
+ self.green = other.green
266
+ self.blue = other.blue
267
+ self.alpha = other.alpha
268
+ end
255
269
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - questionmarkexclamationpoint
8
- autorequire:
7
+ - interrobang
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2019-05-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
14
- email:
13
+ description:
14
+ email:
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
@@ -19,11 +19,11 @@ files:
19
19
  - lib/integer.rb
20
20
  - lib/string.rb
21
21
  - lib/tinct.rb
22
- homepage:
22
+ homepage:
23
23
  licenses:
24
24
  - MIT
25
25
  metadata: {}
26
- post_install_message:
26
+ post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
@@ -38,9 +38,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
- rubyforge_project:
42
- rubygems_version: 2.7.6
43
- signing_key:
41
+ rubyforge_project:
42
+ rubygems_version: 2.7.9
43
+ signing_key:
44
44
  specification_version: 4
45
45
  summary: A library that adds a simple color type.
46
46
  test_files: []