skia_safe/core/
arc.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use skia_bindings as sb;

use crate::{scalar, Rect};

pub use sb::SkArc_Type as Type;
variant_name!(Type::Wedge);

/// Represents an arc along an oval boundary, or a closed wedge of the oval.
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Default)]
pub struct Arc {
    /// Bounds of oval containing the arc.
    pub oval: Rect,
    /// Angle in degrees where the arc begins. Zero means horizontally to the right.
    pub start_angle: scalar,
    /// Sweep angle in degrees; positive is clockwise.
    pub sweep_angle: scalar,
    pub ty: Type,
}
native_transmutable!(sb::SkArc, Arc, arc_layout);

impl Arc {
    pub fn new(
        oval: impl AsRef<Rect>,
        start_angle_degrees: scalar,
        sweep_angle_degrees: scalar,
        ty: Type,
    ) -> Self {
        Self {
            oval: *oval.as_ref(),
            start_angle: start_angle_degrees,
            sweep_angle: sweep_angle_degrees,
            ty,
        }
    }

    pub fn is_wedge(&self) -> bool {
        self.ty == Type::Wedge
    }
}