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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#[allow(unused_imports)]
use serde::Serialize;

#[derive(Default, Serialize)]
pub struct Animation<> {
    #[serde(rename = "mode")]
    #[serde(skip_serializing_if = "Option::is_none")]
    mode: Option<Mode>,
    #[serde(rename = "direction")]
    #[serde(skip_serializing_if = "Option::is_none")]
    direction: Option<Direction>,
    #[serde(rename = "fromcurrent")]
    #[serde(skip_serializing_if = "Option::is_none")]
    fromcurrent: Option<bool>,
    #[serde(rename = "frame")]
    #[serde(skip_serializing_if = "crate::IsEmpty::is_empty")]
    frame: crate::IsEmpty<Frame<>>,
    #[serde(rename = "transition")]
    #[serde(skip_serializing_if = "crate::IsEmpty::is_empty")]
    transition: crate::IsEmpty<Transition<>>,
}

impl<> Animation<> {
    /// Describes how a new animate call interacts with currently-running animations. If `immediate`, current animations are interrupted and the new animation is started. If `next`, the current frame is allowed to complete, after which the new animation is started. If `afterall` all existing frames are animated to completion before the new animation is started.
    ///
    /// default: `afterall`
    pub fn mode(&mut self, mode: Mode) -> &mut Self {
        self.mode = Some(mode);
        self
    }
    /// The direction in which to play the frames triggered by the animation call
    ///
    /// default: `forward`
    pub fn direction(&mut self, direction: Direction) -> &mut Self {
        self.direction = Some(direction);
        self
    }
    /// Play frames starting at the current frame instead of the beginning.
    ///
    /// default: `false`
    pub fn fromcurrent(&mut self, fromcurrent: bool) -> &mut Self {
        self.fromcurrent = Some(fromcurrent);
        self
    }
    pub fn frame(&mut self) -> &mut Frame<> {
        self.frame.is_empty = false;
        &mut self.frame.data
    }
    pub fn transition(&mut self) -> &mut Transition<> {
        self.transition.is_empty = false;
        &mut self.transition.data
    }
}
pub enum Mode {
    Immediate,
    Next,
    Afterall,
}
impl serde::Serialize for Mode {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            Self::Immediate => serializer.serialize_str("immediate"),
            Self::Next => serializer.serialize_str("next"),
            Self::Afterall => serializer.serialize_str("afterall"),
        }
    }
}
pub enum Direction {
    Forward,
    Reverse,
}
impl serde::Serialize for Direction {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            Self::Forward => serializer.serialize_str("forward"),
            Self::Reverse => serializer.serialize_str("reverse"),
        }
    }
}

#[derive(Default, Serialize)]
pub struct Frame<> {
    #[serde(rename = "duration")]
    #[serde(skip_serializing_if = "Option::is_none")]
    duration: Option<f64>,
    #[serde(rename = "redraw")]
    #[serde(skip_serializing_if = "Option::is_none")]
    redraw: Option<bool>,
}

impl<> Frame<> {
    /// The duration in milliseconds of each frame. If greater than the frame duration, it will be limited to the frame duration.
    ///
    /// default: `500`
    pub fn duration(&mut self, duration: f64) -> &mut Self {
        self.duration = Some(duration);
        self
    }
    /// Redraw the plot at completion of the transition. This is desirable for transitions that include properties that cannot be transitioned, but may significantly slow down updates that do not require a full redraw of the plot
    ///
    /// default: `true`
    pub fn redraw(&mut self, redraw: bool) -> &mut Self {
        self.redraw = Some(redraw);
        self
    }
}

#[derive(Default, Serialize)]
pub struct Transition<> {
    #[serde(rename = "duration")]
    #[serde(skip_serializing_if = "Option::is_none")]
    duration: Option<f64>,
    #[serde(rename = "easing")]
    #[serde(skip_serializing_if = "Option::is_none")]
    easing: Option<transition::Easing>,
    #[serde(rename = "ordering")]
    #[serde(skip_serializing_if = "Option::is_none")]
    ordering: Option<transition::Ordering>,
}

impl<> Transition<> {
    /// The duration of the transition, in milliseconds. If equal to zero, updates are synchronous.
    ///
    /// default: `500`
    pub fn duration(&mut self, duration: f64) -> &mut Self {
        self.duration = Some(duration);
        self
    }
    /// The easing function used for the transition
    ///
    /// default: `cubic-in-out`
    pub fn easing(&mut self, easing: transition::Easing) -> &mut Self {
        self.easing = Some(easing);
        self
    }
    /// Determines whether the figure's layout or traces smoothly transitions during updates that make both traces and layout change.
    ///
    /// default: `layout first`
    pub fn ordering(&mut self, ordering: transition::Ordering) -> &mut Self {
        self.ordering = Some(ordering);
        self
    }
}
pub mod transition {
#[allow(unused_imports)]
use serde::Serialize;
pub enum Easing {
    Linear,
    Quad,
    Cubic,
    Sin,
    Exp,
    Circle,
    Elastic,
    Back,
    Bounce,
    LinearIn,
    QuadIn,
    CubicIn,
    SinIn,
    ExpIn,
    CircleIn,
    ElasticIn,
    BackIn,
    BounceIn,
    LinearOut,
    QuadOut,
    CubicOut,
    SinOut,
    ExpOut,
    CircleOut,
    ElasticOut,
    BackOut,
    BounceOut,
    LinearInOut,
    QuadInOut,
    CubicInOut,
    SinInOut,
    ExpInOut,
    CircleInOut,
    ElasticInOut,
    BackInOut,
    BounceInOut,
}
impl serde::Serialize for Easing {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            Self::Linear => serializer.serialize_str("linear"),
            Self::Quad => serializer.serialize_str("quad"),
            Self::Cubic => serializer.serialize_str("cubic"),
            Self::Sin => serializer.serialize_str("sin"),
            Self::Exp => serializer.serialize_str("exp"),
            Self::Circle => serializer.serialize_str("circle"),
            Self::Elastic => serializer.serialize_str("elastic"),
            Self::Back => serializer.serialize_str("back"),
            Self::Bounce => serializer.serialize_str("bounce"),
            Self::LinearIn => serializer.serialize_str("linear-in"),
            Self::QuadIn => serializer.serialize_str("quad-in"),
            Self::CubicIn => serializer.serialize_str("cubic-in"),
            Self::SinIn => serializer.serialize_str("sin-in"),
            Self::ExpIn => serializer.serialize_str("exp-in"),
            Self::CircleIn => serializer.serialize_str("circle-in"),
            Self::ElasticIn => serializer.serialize_str("elastic-in"),
            Self::BackIn => serializer.serialize_str("back-in"),
            Self::BounceIn => serializer.serialize_str("bounce-in"),
            Self::LinearOut => serializer.serialize_str("linear-out"),
            Self::QuadOut => serializer.serialize_str("quad-out"),
            Self::CubicOut => serializer.serialize_str("cubic-out"),
            Self::SinOut => serializer.serialize_str("sin-out"),
            Self::ExpOut => serializer.serialize_str("exp-out"),
            Self::CircleOut => serializer.serialize_str("circle-out"),
            Self::ElasticOut => serializer.serialize_str("elastic-out"),
            Self::BackOut => serializer.serialize_str("back-out"),
            Self::BounceOut => serializer.serialize_str("bounce-out"),
            Self::LinearInOut => serializer.serialize_str("linear-in-out"),
            Self::QuadInOut => serializer.serialize_str("quad-in-out"),
            Self::CubicInOut => serializer.serialize_str("cubic-in-out"),
            Self::SinInOut => serializer.serialize_str("sin-in-out"),
            Self::ExpInOut => serializer.serialize_str("exp-in-out"),
            Self::CircleInOut => serializer.serialize_str("circle-in-out"),
            Self::ElasticInOut => serializer.serialize_str("elastic-in-out"),
            Self::BackInOut => serializer.serialize_str("back-in-out"),
            Self::BounceInOut => serializer.serialize_str("bounce-in-out"),
        }
    }
}
pub enum Ordering {
    LayoutFirst,
    TracesFirst,
}
impl serde::Serialize for Ordering {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            Self::LayoutFirst => serializer.serialize_str("layout first"),
            Self::TracesFirst => serializer.serialize_str("traces first"),
        }
    }
}
}