Module | Rubygame::Color::ColorBase |
In: |
lib/rubygame/color/models/base.rb
|
Perform color multiplication with another color of any type. The alpha of the new color will be equal to the alpha of the receiver.
# File lib/rubygame/color/models/base.rb, line 43 def *(other) wrap( simple_op(other) { |a,b| a * b } ) end
Perform color addition with another color of any type. The alpha of the new color will be equal to the alpha of the receiver.
# File lib/rubygame/color/models/base.rb, line 29 def +(other) wrap( simple_op(other) { |a,b| a + b } ) end
Perform color subtraction with another color of any type. The alpha of the new color will be equal to the alpha of the receiver.
# File lib/rubygame/color/models/base.rb, line 36 def -(other) wrap( simple_op(other) { |a,b| a - b } ) end
Perform color division with another color of any type. The alpha of the new color will be equal to the alpha of the receiver.
# File lib/rubygame/color/models/base.rb, line 50 def /(other) wrap( simple_op(other) { |a,b| a / b } ) end
Average this color with another color. (Linear weighted average)
A weight of 0.0 means 0% of this color, 100% of the other. A weight of 1.0 means 100% of this color, 0% of the other. A weight of 0.5 means 50% of each color.
# File lib/rubygame/color/models/base.rb, line 74 def average(other, weight=0.5) c1, c2 = self.to_rgba_ary, other.to_rgba_ary rgba = [0,1,2,3].collect do |i| clamp( c1.at(i)*weight + c2.at(i)*(1-weight) ) end wrap( rgba ) end