1 | use skia_bindings as sb; |
2 | |
3 | use crate::{scalar, Rect}; |
4 | |
5 | pub use sb::SkArc_Type as Type; |
6 | variant_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)] |
11 | pub 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 | } |
20 | native_transmutable!(sb::SkArc, Arc, arc_layout); |
21 | |
22 | impl 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 | } |
41 | |