rive_rs/animation/
animator.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::{Core, ObjectRef};
6
7pub(crate) struct Animator<T> {
8    val: T,
9}
10
11impl<T: Clone> Animator<T> {
12    pub fn new(val: T) -> Self {
13        Self { val }
14    }
15
16    pub fn animate<'a, C: Core, S>(&self, object: &'a ObjectRef<'a, C>, setter: S)
17    where
18        S: Fn(&'a ObjectRef<'a, C>, T),
19    {
20        setter(object, self.val.clone());
21    }
22}