Class: Unmagic::Color::Gradient::Stop
- Inherits:
-
Object
- Object
- Unmagic::Color::Gradient::Stop
- Defined in:
- lib/unmagic/color/gradient/stop.rb
Overview
A color stop at a specific position in a gradient.
Represents a single color at a position along a gradient. Positions are normalized from 0.0 (start) to 1.0 (end). Multiple stops define the color transitions in a gradient.
## Usage
Stop objects are typically created automatically by gradient classes using the ‘.build()` method, but can be created directly for more control.
## Examples
# Create a stop directly
stop = Unmagic::Color::Gradient::Stop.new(
color: Unmagic::Color::RGB.parse("#FF0000"),
position: 0.5
)
# Access stop properties
stop.color # => #<RGB...>
stop.position # => 0.5
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(color:, position:) ⇒ Stop
constructor
Create a new color stop.
Constructor Details
#initialize(color:, position:) ⇒ Stop
Create a new color stop.
38 39 40 41 42 43 44 |
# File 'lib/unmagic/color/gradient/stop.rb', line 38 def initialize(color:, position:) raise ArgumentError, "color must be a Color instance" unless color.is_a?(Unmagic::Color) raise ArgumentError, "position must be between 0.0 and 1.0" if position < 0.0 || position > 1.0 @color = color @position = position.to_f end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
29 30 31 |
# File 'lib/unmagic/color/gradient/stop.rb', line 29 def color @color end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
29 30 31 |
# File 'lib/unmagic/color/gradient/stop.rb', line 29 def position @position end |