rive_rs/animation/loop.rs
1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::core::TryFromU64;
6
7/// Loop options for linear animations.
8#[derive(Clone, Copy, Debug, Eq, PartialEq)]
9pub enum Loop {
10 /// Play until the duration or end of work area of the animation.
11 OneShot,
12 /// Play until the duration or end of work area of the animation and
13 /// then go back to the start (0 seconds).
14 Loop,
15 /// Play to the end of the duration/work area and then play back.
16 PingPong,
17}
18
19impl Default for Loop {
20 fn default() -> Self {
21 Self::OneShot
22 }
23}
24
25impl TryFromU64 for Loop {
26 fn try_from(value: u64) -> Option<Self> {
27 match value {
28 0 => Some(Self::OneShot),
29 1 => Some(Self::Loop),
30 2 => Some(Self::PingPong),
31 _ => None,
32 }
33 }
34}