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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! Text rendering for HUD, UI, and 3D world text.
//!
//! Render text with SDF (Signed Distance Field) fonts for crisp scaling:
//!
//! - [`HudText`]: Screen-space text anchored to screen edges/center
//! - [`TextProperties`]: Font size, color, alignment, outline settings
//! - [`HudAnchor`]: Screen position anchor (TopLeft, Center, BottomRight, etc.)
//! - [`spawn_hud_text`]: Create screen-space text entity
//! - [`load_font_from_bytes`]: Load custom SDF fonts
//!
//! # Basic HUD Text
//!
//! ```ignore
//! use nightshade::ecs::text::{spawn_hud_text, HudAnchor};
//!
//! // Score display in top-left
//! let score_text = spawn_hud_text(
//! world,
//! "Score: 0",
//! HudAnchor::TopLeft,
//! Vec2::new(20.0, 20.0), // Offset from anchor
//! );
//! ```
//!
//! # Styled Text
//!
//! ```ignore
//! use nightshade::ecs::text::{spawn_hud_text_with_properties, TextProperties, HudAnchor};
//!
//! let title = spawn_hud_text_with_properties(
//! world,
//! "GAME OVER",
//! HudAnchor::Center,
//! Vec2::zeros(),
//! TextProperties {
//! font_size: 48.0,
//! color: Vec4::new(1.0, 0.2, 0.2, 1.0), // Red
//! alignment: TextAlignment::Center,
//! outline_width: 2.0,
//! outline_color: Vec4::new(0.0, 0.0, 0.0, 1.0),
//! ..Default::default()
//! },
//! );
//! ```
//!
//! # Updating Text Content
//!
//! ```ignore
//! // Update the text string
//! let new_index = world.resources.text_cache.add_text(format!("Score: {}", score));
//!
//! if let Some(hud_text) = world.get_hud_text_mut(score_text) {
//! hud_text.set_text_index(new_index);
//! }
//! ```
//!
//! # Screen Anchors
//!
//! | Anchor | Position |
//! |--------|----------|
//! | `TopLeft` | Top-left corner |
//! | `TopCenter` | Top edge, centered |
//! | `TopRight` | Top-right corner |
//! | `CenterLeft` | Left edge, vertically centered |
//! | `Center` | Screen center |
//! | `CenterRight` | Right edge, vertically centered |
//! | `BottomLeft` | Bottom-left corner |
//! | `BottomCenter` | Bottom edge, centered |
//! | `BottomRight` | Bottom-right corner |
//!
//! # Text Properties
//!
//! | Property | Description | Default |
//! |----------|-------------|---------|
//! | `font_size` | Size in pixels | 16.0 |
//! | `color` | RGBA color | White |
//! | `alignment` | Left, Center, Right | Left |
//! | `vertical_alignment` | Top, Middle, Bottom, Baseline | Baseline |
//! | `line_height` | Line spacing multiplier | 1.2 |
//! | `letter_spacing` | Extra space between characters | 0.0 |
//! | `outline_width` | Outline thickness | 0.0 |
//! | `outline_color` | Outline RGBA color | Black |
//!
//! # Loading Custom Fonts
//!
//! Load SDF fonts generated with tools like msdf-atlas-gen:
//!
//! ```ignore
//! let font_data = include_bytes!("../assets/my_font.ttf").to_vec();
//! let font_index = load_font_from_bytes(world, font_data, 48.0)?;
//!
//! // Use custom font
//! let text = spawn_hud_text(world, "Custom Font", HudAnchor::Center, Vec2::zeros());
//! if let Some(hud_text) = world.get_hud_text_mut(text) {
//! hud_text.set_font_index(font_index);
//! }
//! ```
//!
//! # Dynamic Color Changes
//!
//! ```ignore
//! if let Some(hud_text) = world.get_hud_text_mut(health_text) {
//! let mut props = hud_text.properties.clone();
//! props.color = if health < 25 {
//! Vec4::new(1.0, 0.0, 0.0, 1.0) // Red when low
//! } else {
//! Vec4::new(0.0, 1.0, 0.0, 1.0) // Green when healthy
//! };
//! hud_text.set_properties(props);
//! }
//! ```
//!
//! [`HudText`]: components::HudText
//! [`TextProperties`]: components::TextProperties
//! [`HudAnchor`]: components::HudAnchor
//! [`spawn_hud_text`]: commands::spawn_hud_text
//! [`load_font_from_bytes`]: commands::load_font_from_bytes
pub use *;
pub use *;
pub use *;
pub use *;