Class: Rszr::Color::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/rszr/color/point.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position, color) ⇒ Point

Returns a new instance of Point.

Raises:

  • (ArgumentError)


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

#colorObject (readonly)

Returns the value of attribute color.



5
6
7
# File 'lib/rszr/color/point.rb', line 5

def color
  @color
end

#positionObject (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

#prgbaObject



23
24
25
# File 'lib/rszr/color/point.rb', line 23

def prgba
  [position, *color.rgba]
end