1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//! Gradient utilities for color transitions
//!
//! Provides multi-stop gradients with various interpolation modes,
//! directions, and spread modes for terminal UI rendering.
//!
//! # Example
//!
//! ```rust,ignore
//! use revue::utils::gradient::{Gradient, ColorStop};
//! use revue::style::Color;
//!
//! // Create a rainbow gradient
//! let gradient = Gradient::new(vec![
//! ColorStop::new(0.0, Color::RED),
//! ColorStop::new(0.5, Color::GREEN),
//! ColorStop::new(1.0, Color::BLUE),
//! ]);
//!
//! // Get color at position
//! let color = gradient.at(0.25); // Orange-ish
//!
//! // Generate colors for a width
//! let colors = gradient.colors(80); // 80 column gradient
//! ```
// Public re-exports
pub use Gradient;
pub use LinearGradient;
pub use RadialGradient;
pub use ;
/// Apply gradient colors to buffer cells (horizontal gradient)
///
/// Fills a rectangular area with horizontally interpolated gradient colors.
/// Each cell gets its background color set based on its x-position.
///
/// # Arguments
///
/// * `gradient` - The gradient to use
/// * `buffer` - Mutable buffer reference
/// * `x` - Starting x position
/// * `y` - Starting y position
/// * `width` - Width of the area to fill
/// * `height` - Height of the area to fill
///
/// # Example
///
/// ```rust,ignore
/// use revue::utils::gradient::{fill_gradient_horizontal, Gradient, ColorStop};
/// use revue::style::Color;
/// use revue::render::Buffer;
///
/// let mut buffer = Buffer::new(80, 24);
/// let gradient = Gradient::linear(Color::BLUE, Color::RED);
/// fill_gradient_horizontal(&gradient, &mut buffer, 0, 0, 80, 24);
/// ```
/// Apply gradient colors to buffer cells (vertical gradient)
///
/// Fills a rectangular area with vertically interpolated gradient colors.
/// Each cell gets its background color set based on its y-position.
///
/// # Arguments
///
/// * `gradient` - The gradient to use
/// * `buffer` - Mutable buffer reference
/// * `x` - Starting x position
/// * `y` - Starting y position
/// * `width` - Width of the area to fill
/// * `height` - Height of the area to fill
///
/// # Example
///
/// ```rust,ignore
/// use revue::utils::gradient::{fill_gradient_vertical, Gradient, ColorStop};
/// use revue::style::Color;
/// use revue::render::Buffer;
///
/// let mut buffer = Buffer::new(80, 24);
/// let gradient = Gradient::linear(Color::BLACK, Color::WHITE);
/// fill_gradient_vertical(&gradient, &mut buffer, 0, 0, 80, 24);
/// ```
/// Create a gradient suited for UI progress bars
///
/// Creates a smooth gradient from a dim color to a bright color.
/// Useful for progress bars, level indicators, etc.
///
/// # Arguments
///
/// * `base_color` - The base hue (will be dimmed for 0%)
///
/// # Returns
///
/// A gradient from dim(base_color, 0.3) to base_color
/// Create a gradient suited for disabled/ghost states
///
/// Returns a grayscale gradient for disabled elements.