rive_rs/shapes/
straight_vertex.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, OnAdded, Property};
6use crate::shapes::PathVertex;
7
8#[derive(Debug, Default)]
9pub struct StraightVertex {
10    path_vertex: PathVertex,
11    radius: Property<f32>,
12}
13
14impl ObjectRef<'_, StraightVertex> {
15    pub fn radius(&self) -> f32 {
16        self.radius.get()
17    }
18
19    pub fn set_radius(&self, radius: f32) {
20        if self.radius() == radius {
21            return;
22        }
23
24        self.radius.set(radius);
25        self.cast::<PathVertex>().mark_path_dirty();
26    }
27}
28
29impl Core for StraightVertex {
30    parent_types![(path_vertex, PathVertex)];
31
32    properties![(26, radius, set_radius), path_vertex];
33}
34
35impl OnAdded for ObjectRef<'_, StraightVertex> {
36    on_added!(PathVertex);
37}