2025-11-09 03:00:20 +01:00
|
|
|
use crate::parser::color::Color;
|
|
|
|
|
use anyhow::Result;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct ColorPalette {
|
|
|
|
|
colors: Vec<Color>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ColorPalette {
|
|
|
|
|
pub fn new(colors: Vec<Color>) -> Self {
|
|
|
|
|
Self { colors }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn from_strings(color_strs: &[String]) -> Result<Self> {
|
|
|
|
|
let colors: Result<Vec<Color>> = color_strs.iter().map(|s| Color::parse(s)).collect();
|
|
|
|
|
Ok(Self::new(colors?))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn get_color(&self, index: usize) -> Color {
|
|
|
|
|
if self.colors.is_empty() {
|
|
|
|
|
return Color::new(255, 255, 255);
|
|
|
|
|
}
|
|
|
|
|
self.colors[index % self.colors.len()]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn len(&self) -> usize {
|
|
|
|
|
self.colors.len()
|
Initial commit: Piglet - Animated figlet wrapper
Add complete Rust implementation with:
- 20+ motion effects (fade, slide, scale, typewriter, wave, bounce, etc.)
- 18+ easing functions (linear, quad, cubic, elastic, back, bounce)
- Color support (CSS4 colors, hex codes, gradients)
- Figlet integration with custom fonts and options
- Cross-platform support (Linux, macOS, Windows)
- Comprehensive CI/CD workflows
- Full test suite with integration tests
- Documentation (README.md, CLAUDE.md)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 01:53:26 +01:00
|
|
|
}
|
2025-11-09 03:00:20 +01:00
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
|
|
|
self.colors.is_empty()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Create rainbow palette
|
|
|
|
|
pub fn rainbow() -> Self {
|
|
|
|
|
Self::from_strings(&[
|
|
|
|
|
"#ff0000".to_string(),
|
|
|
|
|
"#ff7f00".to_string(),
|
|
|
|
|
"#ffff00".to_string(),
|
|
|
|
|
"#00ff00".to_string(),
|
|
|
|
|
"#0000ff".to_string(),
|
|
|
|
|
"#4b0082".to_string(),
|
|
|
|
|
"#9400d3".to_string(),
|
|
|
|
|
])
|
|
|
|
|
.unwrap()
|
|
|
|
|
}
|
|
|
|
|
|
Initial commit: Piglet - Animated figlet wrapper
Add complete Rust implementation with:
- 20+ motion effects (fade, slide, scale, typewriter, wave, bounce, etc.)
- 18+ easing functions (linear, quad, cubic, elastic, back, bounce)
- Color support (CSS4 colors, hex codes, gradients)
- Figlet integration with custom fonts and options
- Cross-platform support (Linux, macOS, Windows)
- Comprehensive CI/CD workflows
- Full test suite with integration tests
- Documentation (README.md, CLAUDE.md)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 01:53:26 +01:00
|
|
|
/// Create ocean palette
|
2025-11-09 03:00:20 +01:00
|
|
|
#[allow(dead_code)]
|
Initial commit: Piglet - Animated figlet wrapper
Add complete Rust implementation with:
- 20+ motion effects (fade, slide, scale, typewriter, wave, bounce, etc.)
- 18+ easing functions (linear, quad, cubic, elastic, back, bounce)
- Color support (CSS4 colors, hex codes, gradients)
- Figlet integration with custom fonts and options
- Cross-platform support (Linux, macOS, Windows)
- Comprehensive CI/CD workflows
- Full test suite with integration tests
- Documentation (README.md, CLAUDE.md)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 01:53:26 +01:00
|
|
|
pub fn ocean() -> Self {
|
|
|
|
|
Self::from_strings(&[
|
|
|
|
|
"#000080".to_string(),
|
|
|
|
|
"#0000ff".to_string(),
|
|
|
|
|
"#4169e1".to_string(),
|
|
|
|
|
"#87ceeb".to_string(),
|
|
|
|
|
"#add8e6".to_string(),
|
2025-11-09 03:00:20 +01:00
|
|
|
])
|
|
|
|
|
.unwrap()
|
Initial commit: Piglet - Animated figlet wrapper
Add complete Rust implementation with:
- 20+ motion effects (fade, slide, scale, typewriter, wave, bounce, etc.)
- 18+ easing functions (linear, quad, cubic, elastic, back, bounce)
- Color support (CSS4 colors, hex codes, gradients)
- Figlet integration with custom fonts and options
- Cross-platform support (Linux, macOS, Windows)
- Comprehensive CI/CD workflows
- Full test suite with integration tests
- Documentation (README.md, CLAUDE.md)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for ColorPalette {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self::rainbow()
|
|
|
|
|
}
|
2025-11-09 03:00:20 +01:00
|
|
|
}
|