| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
use bevy::color::palettes::css::{BLUE, GREEN, ORANGE, RED, YELLOW}; |
| 7 |
use bevy::prelude::*; |
| 8 |
|
| 9 |
fn main() { |
| 10 |
App::new() |
| 11 |
.add_plugins(DefaultPlugins) |
| 12 |
.add_systems(Startup, setup_camera) |
| 13 |
.add_systems(Update, anchors) |
| 14 |
.run(); |
| 15 |
} |
| 16 |
|
| 17 |
fn setup_camera(mut commands: Commands) { |
| 18 |
commands.spawn(Camera2d); |
| 19 |
} |
| 20 |
|
| 21 |
fn anchors(mut text_gizmos: Gizmos, time: Res<Time>) { |
| 22 |
let t = time.elapsed_secs(); |
| 23 |
for (label, anchor, color) in [ |
| 24 |
("left", vec2(-0.5, 0.0), RED), |
| 25 |
("right", vec2(0.5, 0.0), ORANGE), |
| 26 |
("center", Vec2::ZERO, YELLOW), |
| 27 |
("top", vec2(0.0, 0.5), GREEN), |
| 28 |
("bottom", vec2(0.0, -0.5), BLUE), |
| 29 |
] { |
| 30 |
let position = Vec2::splat(350.0) * anchor; |
| 31 |
text_gizmos.text_2d( |
| 32 |
Isometry2d::from_translation(position), |
| 33 |
"+", |
| 34 |
12., |
| 35 |
Vec2::ZERO, |
| 36 |
Color::WHITE, |
| 37 |
); |
| 38 |
text_gizmos.text_2d( |
| 39 |
Isometry2d::new(position, Rot2::radians(t)), |
| 40 |
label, |
| 41 |
25., |
| 42 |
anchor, |
| 43 |
color, |
| 44 |
); |
| 45 |
} |
| 46 |
} |