Class: Shoes::Gradient

Inherits:
Object
  • Object
show all
Includes:
Comparable, Common::Inspect
Defined in:
shoes-core/lib/shoes/gradient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common::Inspect

#inspect, #to_s

Constructor Details

#initialize(color1, color2, alpha = Shoes::Color::OPAQUE) ⇒ Gradient

Returns a new instance of Gradient.



8
9
10
11
12
# File 'shoes-core/lib/shoes/gradient.rb', line 8

def initialize(color1, color2, alpha = Shoes::Color::OPAQUE)
  @color1 = color1
  @color2 = color2
  @alpha = alpha
end

Instance Attribute Details

#alphaObject (readonly)

Returns the value of attribute alpha.



14
15
16
# File 'shoes-core/lib/shoes/gradient.rb', line 14

def alpha
  @alpha
end

#color1Object (readonly)

Returns the value of attribute color1.



14
15
16
# File 'shoes-core/lib/shoes/gradient.rb', line 14

def color1
  @color1
end

#color2Object (readonly)

Returns the value of attribute color2.



14
15
16
# File 'shoes-core/lib/shoes/gradient.rb', line 14

def color2
  @color2
end

Instance Method Details

#<=>(other) ⇒ Object

arbitrarily compare 1st non-equal color



16
17
18
19
# File 'shoes-core/lib/shoes/gradient.rb', line 16

def <=>(other) # arbitrarily compare 1st non-equal color
  return unless other.is_a?(self.class)
  [color1, color2] <=> [other.color1, other.color2]
end