skia_safe/modules/paragraph/
text_shadow.rs

1use crate::{prelude::*, Color, Point};
2use skia_bindings as sb;
3
4#[repr(C)]
5#[derive(Copy, Clone, Debug)]
6pub struct TextShadow {
7    pub color: Color,
8    pub offset: Point,
9    pub blur_sigma: f64,
10}
11
12native_transmutable!(sb::skia_textlayout_TextShadow, TextShadow);
13
14impl Default for TextShadow {
15    fn default() -> Self {
16        TextShadow::from_native_c(unsafe { sb::skia_textlayout_TextShadow::new() })
17    }
18}
19
20impl PartialEq for TextShadow {
21    fn eq(&self, other: &Self) -> bool {
22        unsafe { sb::C_TextShadow_Equals(self.native(), other.native()) }
23    }
24}
25
26impl TextShadow {
27    pub fn new(color: impl Into<Color>, offset: impl Into<Point>, blur_sigma: f64) -> Self {
28        TextShadow::from_native_c(unsafe {
29            sb::skia_textlayout_TextShadow::new1(
30                color.into().into_native(),
31                offset.into().into_native(),
32                blur_sigma,
33            )
34        })
35    }
36
37    pub fn has_shadow(&self) -> bool {
38        unsafe { self.native().hasShadow() }
39    }
40}