-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use macroquad::prelude::*; | ||
|
||
static LOREM: &str = "Lorem ipsum odor amet, consectetuer adipiscing elit. Ultrices nostra volutpat facilisis magna mus. Rhoncus tempor feugiat netus maecenas pretium leo vitae. Eros aliquet maecenas eu diam aliquet varius hac elementum. Sociosqu platea per ultricies vitae praesent mauris nostra ridiculus. Est cursus pulvinar efficitur mus vel leo. Integer et nec eleifend non leo. Lorem rutrum ultrices potenti facilisis hendrerit facilisi metus sit. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | ||
Intentional newlines | ||
are preserved. | ||
"; | ||
|
||
#[macroquad::main("Text Wrap")] | ||
async fn main() { | ||
let font_size = 24; | ||
loop { | ||
clear_background(BLACK); | ||
|
||
let maximum_line_length = f32::max(20.0, mouse_position().0 - 20.0); | ||
let text = wrap_text(LOREM, None, font_size, 1.0, maximum_line_length); | ||
|
||
draw_multiline_text(&text, 20.0, 20.0, font_size as f32, Some(1.0), WHITE); | ||
draw_line( | ||
20.0 + maximum_line_length, | ||
0.0, | ||
20.0 + maximum_line_length, | ||
screen_height(), | ||
1.0, | ||
RED, | ||
); | ||
|
||
next_frame().await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters