tge/graphics/params/
text.rs1use super::Color;
2use crate::math::Position;
3
4#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
5pub enum TextLayoutGravity {
6 Start,
7 Center,
8 End,
9}
10
11impl Default for TextLayoutGravity {
12 fn default() -> Self {
13 Self::Start
14 }
15}
16
17#[derive(Debug, Default, Clone, PartialEq)]
18pub struct TextDrawParams {
19 pub text_size: Option<f32>,
20 pub char_spacing: Option<f32>,
21 pub line_height: Option<f32>,
22 pub line_spacing: Option<f32>,
23 pub wrap_width: Option<f32>,
24 pub wrap_height: Option<f32>,
25 pub horizontal_gravity: Option<TextLayoutGravity>,
26 pub vertical_gravity: Option<TextLayoutGravity>,
27 pub origin: Option<Position>,
28 pub color: Option<Color>,
29}
30
31impl TextDrawParams {
32 pub fn text_size(mut self, size: f32) -> Self {
33 self.text_size = Some(size);
34 self
35 }
36
37 pub fn char_spacing(mut self, spacing: f32) -> Self {
38 self.char_spacing = Some(spacing);
39 self
40 }
41
42 pub fn line_height(mut self, height: f32) -> Self {
43 self.line_height = Some(height);
44 self
45 }
46
47 pub fn line_spacing(mut self, spacing: f32) -> Self {
48 self.line_spacing = Some(spacing);
49 self
50 }
51
52 pub fn wrap_width(mut self, width: f32) -> Self {
53 self.wrap_width = Some(width);
54 self
55 }
56
57 pub fn wrap_height(mut self, height: f32) -> Self {
58 self.wrap_height = Some(height);
59 self
60 }
61
62 pub fn horizontal_gravity(mut self, gravity: TextLayoutGravity) -> Self {
63 self.horizontal_gravity = Some(gravity);
64 self
65 }
66
67 pub fn vertical_gravity(mut self, gravity: TextLayoutGravity) -> Self {
68 self.vertical_gravity = Some(gravity);
69 self
70 }
71
72 pub fn origin(mut self, origin: impl Into<Position>) -> Self {
73 self.origin = Some(origin.into());
74 self
75 }
76
77 pub fn color(mut self, color: impl Into<Color>) -> Self {
78 self.color = Some(color.into());
79 self
80 }
81}