Class: Rszr::Color::Point
- Inherits:
-
Object
- Object
- Rszr::Color::Point
- Defined in:
- lib/rszr/color/point.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(position, color) ⇒ Point
constructor
A new instance of Point.
- #prgba ⇒ Object
Constructor Details
#initialize(position, color) ⇒ Point
Returns a new instance of Point.
13 14 15 16 17 |
# File 'lib/rszr/color/point.rb', line 13 def initialize(position, color) raise ArgumentError, 'position must be within 0..1' unless (0..1).cover?(position) raise ArgumentError, 'color must be a Rszr::Color::Base' unless color.is_a?(Rszr::Color::Base) @position, @color = position, color end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
5 6 7 |
# File 'lib/rszr/color/point.rb', line 5 def color @color end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
5 6 7 |
# File 'lib/rszr/color/point.rb', line 5 def position @position end |
Class Method Details
.prgba(position, red, green, blue, alpha = 255) ⇒ Object
8 9 10 |
# File 'lib/rszr/color/point.rb', line 8 def prgba(position, red, green, blue, alpha = 255) new(position, RGBA.new(red, green, blue, alpha)) end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 |
# File 'lib/rszr/color/point.rb', line 19 def <=>(other) position <=> other.position end |
#prgba ⇒ Object
23 24 25 |
# File 'lib/rszr/color/point.rb', line 23 def prgba [position, *color.rgba] end |