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