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
//! Colored crate integration.
//!
//! Provides conversion between [`Color`](crate::Color) and [`colored::Color`].
//!
//! Forward conversion always produces [`Color::TrueColor`](colored::Color::TrueColor).
//! Reverse conversion uses [`TryFrom`] since only the `TrueColor` variant can be converted.
//!
//! # Examples
//!
//! ```ignore
//! use prismatica::crameri::BATLOW;
//!
//! let color = BATLOW.eval(0.5);
//! let col_color: colored::Color = color.into();
//!
//! // Reverse: only TrueColor variant converts
//! let back = prismatica::Color::try_from(col_color).unwrap();
//! assert_eq!(color, back);
//! ```
use crateimpl_into_framework_color;
use crate::;
/// Convert a prismatica [`Color`] to a [`colored::Color::TrueColor`].
///
/// # Examples
///
/// ```ignore
/// let color = prismatica::Color::new(128, 64, 32);
/// let col: colored::Color = color.into();
/// ```
/// Try to convert a [`colored::Color`] to a prismatica [`Color`].
///
/// Only the `TrueColor` variant can be converted. Named colors (e.g., `Red`, `Blue`)
/// and other variants return an error.
///
/// # Errors
///
/// Returns [`ConversionError`](crate::ConversionError) if the color is not
/// a `Color::TrueColor` variant.
///
/// # Examples
///
/// ```ignore
/// use prismatica::Color;
///
/// let rgb = colored::Color::TrueColor { r: 128, g: 64, b: 32 };
/// assert!(Color::try_from(rgb).is_ok());
///
/// let named = colored::Color::Red;
/// assert!(Color::try_from(named).is_err());
/// ```
impl_into_framework_color!;