freya_core/style/
text_shadow.rs1use std::hash::Hash;
2
3use freya_engine::prelude::*;
4
5use crate::style::color::Color;
6
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8#[derive(Copy, Clone, Debug, PartialEq, Default)]
9pub struct TextShadow {
10 pub color: Color,
11 pub offset: (f32, f32),
12 pub blur_sigma: f64,
13}
14
15impl Hash for TextShadow {
16 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
17 self.color.hash(state);
18 self.offset.0.to_bits().hash(state);
19 self.offset.1.to_bits().hash(state);
20 self.blur_sigma.to_bits().hash(state);
21 }
22}
23
24impl TextShadow {
25 pub fn new(color: Color, offset: (f32, f32), blur_sigma: f64) -> Self {
26 Self {
27 color,
28 offset,
29 blur_sigma,
30 }
31 }
32}
33
34impl From<TextShadow> for SkTextShadow {
35 fn from(value: TextShadow) -> Self {
36 let color: SkColor = value.color.into();
37 SkTextShadow::new(
38 color,
39 SkPoint::new(value.offset.0, value.offset.1),
40 value.blur_sigma,
41 )
42 }
43}