1use super::{
2 Direction, HDRColor, InkAnimDefinition, InkAnimInterpolator, Interpolator, Mode, Range,
3 Transformation, Type, Vector2,
4};
5
6impl std::fmt::Display for Direction {
7 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8 write!(
9 f,
10 "{}",
11 match self {
12 Self::To => "To",
13 Self::From => "From",
14 Self::FromTo => "FromTo",
15 }
16 )
17 }
18}
19
20impl std::fmt::Display for Mode {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 write!(
23 f,
24 "{}",
25 match self {
26 Self::EasyIn => "EasyIn",
27 Self::EasyOut => "EasyOut",
28 Self::EasyInOut => "EasyInOut",
29 }
30 )
31 }
32}
33
34impl std::fmt::Display for Vector2 {
35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 write!(f, "X: {}, Y: {}", self.x, self.y)
37 }
38}
39
40impl std::fmt::Display for HDRColor {
41 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 write!(
43 f,
44 "R:{}, G: {}, B: {}, A: {}",
45 self.red, self.green, self.blue, self.alpha
46 )
47 }
48}
49
50impl std::fmt::Display for Range {
51 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52 match self {
53 Self::Position(position) => write!(f, "{position}"),
54 Self::Color(color) => write!(f, "{color}"),
55 Self::Percent(percent) => write!(f, "{percent}"),
56 }
57 }
58}
59
60impl std::fmt::Display for Type {
61 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
62 write!(
63 f,
64 "{}",
65 match self {
66 Self::Linear => "Linear",
67 Self::Quadratic => "Quadratic",
68 Self::Qubic => "Qubic",
69 Self::Quartic => "Quartic",
70 Self::Quintic => "Quintic",
71 Self::Sinusoidal => "Sinusoidal",
72 Self::Exponential => "Exponential",
73 Self::Elastic => "Elastic",
74 Self::Circular => "Circular",
75 Self::Back => "Back",
76 }
77 )
78 }
79}
80
81impl std::fmt::Display for Interpolator {
82 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83 write!(
84 f,
85 "{} => {} starts at {}, until {} (duration: {}, relative: {})",
86 self.start_value,
87 self.end_value,
88 self.start_delay,
89 self.start_delay + self.duration,
90 self.duration,
91 self.use_relative_duration
92 )
93 }
94}
95
96impl std::fmt::Display for InkAnimInterpolator {
97 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
98 let emoji = self.as_emoji();
99 write!(f, "{} {}", emoji, self.as_ref())
100 }
101}
102
103impl std::fmt::Display for InkAnimDefinition {
104 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
105 write!(
106 f,
107 "{}",
108 self.interpolators
109 .iter()
110 .enumerate()
111 .map(|(idx, x)| { format!("[{idx}] {x}") })
112 .collect::<Vec<String>>()
113 .join("\n")
114 )
115 }
116}
117
118impl std::fmt::Display for Transformation {
119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120 match (&self.from, &self.to) {
121 (Range::Percent(from), Range::Percent(to)) if from == to => {
122 write!(f, "{}%", from * 100.,)
123 }
124 (Range::Percent(from), Range::Percent(to)) => {
125 write!(f, "{}% => {}%", from * 100., to * 100.,)
126 }
127 (Range::Position(from), Range::Position(to)) if from == to => {
128 write!(f, "{from}",)
129 }
130 (Range::Position(from), Range::Position(to)) => write!(f, "{from} => {to}",),
131 (Range::Color(from), Range::Color(to)) if from == to => {
132 write!(f, "{from}")
133 }
134 (Range::Color(from), Range::Color(to)) => write!(f, "{from} => {to}",),
135 (from, to) => panic!(
136 "interpolation start value and end value differ\nstart value: {from:#?}\nend value: {to:#?}"
137 ),
138 }
139 }
140}
141
142impl InkAnimInterpolator {
143 pub fn as_emoji(&self) -> &str {
144 match self {
145 Self::inkanimScaleInterpolator(_) => "♻️",
146 Self::inkanimTranslationInterpolator(_) => "↕️",
147 Self::inkanimTransparencyInterpolator(_) => "👻",
148 Self::inkanimSizeInterpolator(_) => "📏",
149 Self::inkanimColorInterpolator(_) => "🎨",
150 Self::inkanimTextValueProgressInterpolator(_) => "🈺",
151 Self::inkanimEffectInterpolator(_) => "✨",
152 Self::inkanimAnchorInterpolator(_) => "⚓",
153 Self::inkanimPivotInterpolator(_) => "🔛",
154 Self::inkanimShearInterpolator(_) => "〰️",
155 Self::inkanimRotationInterpolator(_) => "🔄",
156 Self::inkanimMarginInterpolator(_) => "➡️",
157 Self::inkanimPaddingInterpolator(_) => "⬅️",
158 Self::inkanimTextReplaceInterpolator(_) => "🈁",
159 Self::inkanimTextOffsetInterpolator(_) => "🆙",
160 }
161 }
162}