slippyd-colorist 0.0.3.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/colorist.gemspec +2 -2
  2. data/lib/colorist/color.rb +42 -0
  3. metadata +2 -2
data/colorist.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'colorist'
5
- s.version = '0.0.3.1'
5
+ s.version = '0.0.4'
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Michael Bleigh", "oleg dashevskii", "Slippy Douglas"]
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
 
34
34
  if s.respond_to? :specification_version then
35
35
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
36
- s.specification_version = 3
36
+ s.specification_version = 4
37
37
 
38
38
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
39
39
  else
@@ -138,6 +138,48 @@ module Colorist
138
138
  color
139
139
  end
140
140
 
141
+ # Multiply the individual RGB values of two colors together or against a Float.
142
+ # Colors divided in a way that is equivalent to each of the values being normalized to 0.0..1.0 prior to the operation
143
+ # and normalized back to 0.0..255.0 after the operation.
144
+ # You may also use an equivalent numeric or string color representation.
145
+ def *(other)
146
+ color = self.dup
147
+
148
+ if other.is_a? Float
149
+ color.r *= other
150
+ color.g *= other
151
+ color.b *= other
152
+ else
153
+ other_color = self.class.from(other)
154
+ color.r = color.r * other_color.r / 255.0
155
+ color.g = color.g * other_color.g / 255.0
156
+ color.b = color.b * other_color.b / 255.0
157
+ end
158
+
159
+ color
160
+ end
161
+
162
+ # Divide the individual RGB values of the two colors together or against a Float.
163
+ # Colors divided in a way that is equivalent to each of the values being normalized to 0.0..1.0 prior to the operation
164
+ # and normalized back to 0.0..255.0 after the operation.
165
+ # You may also use an equivalent numeric or string color representation.
166
+ def /(other)
167
+ color = self.dup
168
+
169
+ if other.is_a? Float
170
+ color.r /= other
171
+ color.g /= other
172
+ color.b /= other
173
+ else
174
+ other_color = self.class.from(other)
175
+ color.r = color.r / other_color.r * 255.0
176
+ color.g = color.g / other_color.g * 255.0
177
+ color.b = color.b / other_color.b * 255.0
178
+ end
179
+
180
+ color
181
+ end
182
+
141
183
  # Compares colors based on brightness.
142
184
  def <=>(other_color)
143
185
  other_color = self.class.from(other_color)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slippyd-colorist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -60,7 +60,7 @@ requirements: []
60
60
  rubyforge_project:
61
61
  rubygems_version: 1.2.0
62
62
  signing_key:
63
- specification_version: 3
63
+ specification_version: 4
64
64
  summary: A library built to handle the easy conversion and simple manipulation of colors.
65
65
  test_files: []
66
66