rive_rs/importers/
keyed_property_importer.rs

1use crate::animation::{KeyFrame, KeyedProperty, LinearAnimation};
2use crate::core::Object;
3use crate::importers::ImportStackObject;
4
5// Copyright 2021 The Fuchsia Authors. All rights reserved.
6// Use of this source code is governed by a BSD-style license that can be
7// found in the LICENSE file.
8
9#[derive(Debug)]
10pub struct KeyedPropertyImporter {
11    animation: Object<LinearAnimation>,
12    keyed_property: Object<KeyedProperty>,
13}
14
15impl KeyedPropertyImporter {
16    pub fn new(animation: Object<LinearAnimation>, keyed_property: Object<KeyedProperty>) -> Self {
17        Self { animation, keyed_property }
18    }
19
20    pub fn push_key_frame(&self, key_frame: Object<KeyFrame>) {
21        key_frame.as_ref().compute_seconds(self.animation.as_ref().fps());
22        self.keyed_property.as_ref().push_key_frame(key_frame);
23    }
24}
25
26impl ImportStackObject for KeyedPropertyImporter {}