skia_safe/modules/paragraph/
text_shadow.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
41
42
43
44
use crate::{prelude::*, Color, Point};
use skia_bindings as sb;

#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct TextShadow {
    pub color: Color,
    pub offset: Point,
    pub blur_sigma: f64,
}

native_transmutable!(
    sb::skia_textlayout_TextShadow,
    TextShadow,
    text_shadow_layout
);

impl Default for TextShadow {
    fn default() -> Self {
        TextShadow::from_native_c(unsafe { sb::skia_textlayout_TextShadow::new() })
    }
}

impl PartialEq for TextShadow {
    fn eq(&self, other: &Self) -> bool {
        unsafe { sb::C_TextShadow_Equals(self.native(), other.native()) }
    }
}

impl TextShadow {
    pub fn new(color: impl Into<Color>, offset: impl Into<Point>, blur_sigma: f64) -> Self {
        TextShadow::from_native_c(unsafe {
            sb::skia_textlayout_TextShadow::new1(
                color.into().into_native(),
                offset.into().into_native(),
                blur_sigma,
            )
        })
    }

    pub fn has_shadow(&self) -> bool {
        unsafe { self.native().hasShadow() }
    }
}