class

CrImage::Draw::ConicGradient

Inherits Reference / Object

ConicGradient represents an angular/conic color gradient sweeping around a center point.

The gradient interpolates colors based on angle from the center, creating a "pie chart" or "gauge" style effect. Useful for gauge charts, color wheels, and angular progress indicators.

Example:

stops = [
  CrImage::Draw::ColorStop.new(0.0, CrImage::Color::RED),
  CrImage::Draw::ColorStop.new(0.5, CrImage::Color::YELLOW),
  CrImage::Draw::ColorStop.new(1.0, CrImage::Color::GREEN),
]
gradient = CrImage::Draw::ConicGradient.new(
  CrImage.point(200, 150),
  stops,
  start_angle: -Math::PI / 2 # Start from top
)

Constructors

new(center : CrImage::Point, stops : Array(CrImage::Draw::ColorStop), start_angle : Float64 = 0.0)
Source

Instance methods

center
Source
center=(center : Point)
Source
color_at(t : Float64) : Color::Color

Gets the interpolated color at a given angle.

Parameters:

  • t : Normalized angle position (0.0 = start_angle, 1.0 = start_angle + 2π)

Returns: Interpolated color at angle t

Source
start_angle
Source
start_angle=(start_angle : Float64)
Source
stops
Source
stops=(stops : Array(ColorStop))
Source