class

CrImage::Draw::LinearGradient

Inherits Reference / Object

LinearGradient represents a linear color gradient between two points.

The gradient interpolates colors along a line from start_point to end_point, using the defined color stops. Colors are smoothly blended between stops.

Example:

stops = [
  CrImage::Draw::ColorStop.new(0.0, CrImage::Color::RED),
  CrImage::Draw::ColorStop.new(0.5, CrImage::Color::GREEN),
  CrImage::Draw::ColorStop.new(1.0, CrImage::Color::BLUE),
]
gradient = CrImage::Draw::LinearGradient.new(
  CrImage.point(0, 0),
  CrImage.point(100, 0),
  stops
)

Constructors

new(start_point : CrImage::Point, end_point : CrImage::Point, stops : Array(CrImage::Draw::ColorStop))
Source

Instance methods

color_at(t : Float64) : Color::Color

Gets the interpolated color at a given position along the gradient.

Parameters:

  • t : Position along gradient (0.0 = start, 1.0 = end)

Returns: Interpolated color at position t

Source
end_point
Source
end_point=(end_point : Point)
Source
start_point
Source
start_point=(start_point : Point)
Source
stops
Source
stops=(stops : Array(ColorStop))
Source