pigment 0.1.8 → 0.1.9

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 (2) hide show
  1. data/lib/pigment.rb +14 -13
  2. metadata +3 -2
data/lib/pigment.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Pigment
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
 
4
4
  class Color
5
5
 
@@ -49,7 +49,7 @@ module Pigment
49
49
  end
50
50
 
51
51
  def hsl
52
- to_hsl
52
+ to_hsl unless @hsl
53
53
  @hsl
54
54
  end
55
55
 
@@ -82,10 +82,10 @@ module Pigment
82
82
  end
83
83
 
84
84
 
85
- # Supress an array of floats by dividing by the greatest color component.
85
+ # Suppress an array of floats by dividing by the greatest color component.
86
86
  # @param [Array] color
87
87
  # @return [Array]
88
- def self.supress(color)
88
+ def self.suppress(color)
89
89
  color.map! { |c| c / color.max } unless (0.0..1.0).include?(color.max)
90
90
  color
91
91
  end
@@ -117,26 +117,26 @@ module Pigment
117
117
  inv
118
118
  end
119
119
 
120
- # Sums all the two colors components. If any component gets out of the 0 to 1.0 range its supressed.
120
+ # Sums all the two colors components. If any component gets out of the 0 to 1.0 range its suppressed.
121
121
  # @param [Numeric] color
122
122
  # @return [Color]
123
123
  def +(color)
124
124
  case color
125
125
  when Color
126
- self.class.new(*supress([color.rgb, rgb].transpose.map! { |c, d| c + d }))
126
+ self.class.new(*self.class.suppress([color.rgb, rgb].transpose.map! { |c, d| c + d }))
127
127
  else
128
128
  raise ArgumentError, "Expecting Color. Given #{color.class}"
129
129
  end
130
130
  end
131
131
 
132
- # Subtracts all the two color components. If any component gets out of the 0 to 1.0 range its supressed.
132
+ # Subtracts all the two color components. If any component gets out of the 0 to 1.0 range its suppressed.
133
133
  # If tone component gets lower than 0 it acts like its dealing with the inverse component -> 1 - component
134
134
  # @param [Numeric] color
135
135
  # @return [Color]
136
136
  def -(color)
137
137
  case color
138
138
  when Color
139
- self.class.new(*self.class.supress([rgb, color.rgb].transpose.map! do |c, d|
139
+ self.class.new(*self.class.suppress([rgb, color.rgb].transpose.map! do |c, d|
140
140
  e = c - d
141
141
  e >= 0 ? e : e = 1 + e
142
142
  e
@@ -146,27 +146,27 @@ module Pigment
146
146
  end
147
147
  end
148
148
 
149
- # Multiplies all the color components by n. If any component gets out of the 0 to 1.0 range its supressed.
149
+ # Multiplies all the color components by n. If any component gets out of the 0 to 1.0 range its suppressed.
150
150
  # @param [Numeric] n
151
151
  # @return [Color]
152
152
  def *(n)
153
153
  case n
154
154
  when Numeric
155
155
  n = rgb.map { |c| c * n.to_f }
156
- self.class.new(*self.class.supress(n))
156
+ self.class.new(*self.class.suppress(n))
157
157
  else
158
158
  raise ArgumentError, "Expecting Numeric. Given #{n.class}"
159
159
  end
160
160
  end
161
161
 
162
- # Divides all the color components by n. If any component gets out of the 0 to 1.0 range its supressed.
162
+ # Divides all the color components by n. If any component gets out of the 0 to 1.0 range its suppressed.
163
163
  # @param [Numeric] n
164
164
  # @return [Color]
165
165
  def /(n)
166
166
  case n
167
167
  when Numeric
168
168
  n = rgb.map { |c| c * n.to_f }
169
- self.class.new(*self.class.supress(n))
169
+ self.class.new(*self.class.suppress(n))
170
170
  else
171
171
  raise ArgumentError, "Expecting Numeric. Given #{n.class}"
172
172
  end
@@ -211,7 +211,7 @@ module Pigment
211
211
  def interpolate(color, amount = 0.5)
212
212
  if color.is_a? Color && (-1.0..1.0).include?(amount)
213
213
  n = [rgb, color.rgb].transpose.map! { |c, d| c + amount * (d - c) }
214
- self.class.new(*self.class.supress(n))
214
+ self.class.new(*self.class.suppress(n))
215
215
  else
216
216
  raise ArgumentError
217
217
  end
@@ -291,6 +291,7 @@ module Pigment
291
291
  "Color(r=#{r}, g=#{g}, b=#{b}, a=#{a}#{", [h=#{h}, s=#{s}, l=#{l}]" if @hsl})"
292
292
  end
293
293
 
294
+ alias_method :alpha=, :a=
294
295
  alias_method :inv, :inverse
295
296
  alias_method :invert, :inverse
296
297
  alias_method :complementary, :inverse
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pigment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-16 00:00:00.000000000 Z
13
+ date: 2012-11-18 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: A rgb color gem, with a list of 750 diferent colors defined within 869
16
16
  names.
@@ -49,3 +49,4 @@ signing_key:
49
49
  specification_version: 3
50
50
  summary: A rgb color gem, with a list of 750 diferent colors.
51
51
  test_files: []
52
+ has_rdoc: