skia_safe/core/
arc.rs

1use skia_bindings as sb;
2
3use crate::{scalar, Rect};
4
5pub use sb::SkArc_Type as Type;
6variant_name!(Type::Wedge);
7
8/// Represents an arc along an oval boundary, or a closed wedge of the oval.
9#[repr(C)]
10#[derive(Debug, Copy, Clone, PartialEq, Default)]
11pub struct Arc {
12    /// Bounds of oval containing the arc.
13    pub oval: Rect,
14    /// Angle in degrees where the arc begins. Zero means horizontally to the right.
15    pub start_angle: scalar,
16    /// Sweep angle in degrees; positive is clockwise.
17    pub sweep_angle: scalar,
18    pub ty: Type,
19}
20native_transmutable!(sb::SkArc, Arc, arc_layout);
21
22impl Arc {
23    pub fn new(
24        oval: impl AsRef<Rect>,
25        start_angle_degrees: scalar,
26        sweep_angle_degrees: scalar,
27        ty: Type,
28    ) -> Self {
29        Self {
30            oval: *oval.as_ref(),
31            start_angle: start_angle_degrees,
32            sweep_angle: sweep_angle_degrees,
33            ty,
34        }
35    }
36
37    pub fn is_wedge(&self) -> bool {
38        self.ty == Type::Wedge
39    }
40}