2022-08-06 10:28:12 +02:00
|
|
|
use std::f32::consts::PI;
|
|
|
|
|
2022-08-06 08:42:08 +02:00
|
|
|
use bevy::prelude::Vec2;
|
|
|
|
use bevy_prototype_lyon::prelude::{Path, PathBuilder};
|
|
|
|
|
|
|
|
pub fn turtle() -> Path {
|
|
|
|
let polygon = &[
|
|
|
|
[-2.5f32, 14.0f32],
|
|
|
|
[-1.25f32, 10.0f32],
|
|
|
|
[-4.0f32, 7.0f32],
|
|
|
|
[-7.0f32, 9.0f32],
|
|
|
|
[-9.0f32, 8.0f32],
|
|
|
|
[-6.0f32, 5.0f32],
|
|
|
|
[-7.0f32, 1.0f32],
|
|
|
|
[-5.0f32, -3.0f32],
|
|
|
|
[-8.0f32, -6.0f32],
|
|
|
|
[-6.0f32, -8.0f32],
|
|
|
|
[-4.0f32, -5.0f32],
|
|
|
|
[0.0f32, -7.0f32],
|
|
|
|
[4.0f32, -5.0f32],
|
|
|
|
[6.0f32, -8.0f32],
|
|
|
|
[8.0f32, -6.0f32],
|
|
|
|
[5.0f32, -3.0f32],
|
|
|
|
[7.0f32, 1.0f32],
|
|
|
|
[6.0f32, 5.0f32],
|
|
|
|
[9.0f32, 8.0f32],
|
|
|
|
[7.0f32, 9.0f32],
|
|
|
|
[4.0f32, 7.0f32],
|
|
|
|
[1.25f32, 10.0f32],
|
|
|
|
[2.5f32, 14.0f32],
|
|
|
|
];
|
|
|
|
let mut turtle_path = PathBuilder::new();
|
|
|
|
turtle_path.line_to(Vec2::new(1.0, 1.0));
|
|
|
|
turtle_path.line_to(Vec2::new(-1.0, 1.0));
|
|
|
|
turtle_path.line_to(Vec2::new(-1.0, -1.0));
|
|
|
|
turtle_path.line_to(Vec2::new(1.0, -1.0));
|
|
|
|
turtle_path.close();
|
2022-08-06 10:28:12 +02:00
|
|
|
turtle_path.move_to(Vec2::new(0.0, 16.0).rotate(Vec2::from_angle(-PI / 2.)));
|
2022-08-06 08:42:08 +02:00
|
|
|
for coord in polygon {
|
2022-08-06 10:28:12 +02:00
|
|
|
turtle_path.line_to(Vec2::from_array(*coord).rotate(Vec2::from_angle(-PI / 2.)));
|
2022-08-06 08:42:08 +02:00
|
|
|
}
|
|
|
|
turtle_path.close();
|
|
|
|
turtle_path.build()
|
|
|
|
}
|