```rust
// Movement
plan.forward(100);
plan.backward(50);
// Rotation
plan.left(90); // degrees
plan.right(45);
// Circular arcs
plan.circle_left(50.0, 180.0, 36); // radius, angle (degrees), segments
plan.circle_right(50.0, 180.0, 36); // draws arc to the right
// Pen control
plan.pen_up();
plan.pen_down();
// Appearance
plan.set_color(RED);
plan.set_pen_width(5.0);
plan.hide();
plan.show();
// Turtle shape
plan.shape(ShapeType::Triangle);
plan.shape(ShapeType::Turtle); // Default classic turtle shape
plan.shape(ShapeType::Circle);
plan.shape(ShapeType::Square);
plan.shape(ShapeType::Arrow);
// Custom shape
let custom = TurtleShape::new(
vec![vec2(10.0, 0.0), vec2(-5.0, 5.0), vec2(-5.0, -5.0)],
true // filled
);
plan.set_shape(custom);
// Chaining
plan.forward(100).right(90).forward(50);
```
25 lines
520 B
Rust
25 lines
520 B
Rust
//! General types and type aliases used throughout the turtle library
|
|
|
|
use macroquad::prelude::*;
|
|
|
|
pub mod angle;
|
|
pub mod length;
|
|
|
|
pub use angle::Angle;
|
|
pub use length::Length;
|
|
|
|
/// Precision type for calculations
|
|
pub type Precision = f32;
|
|
|
|
/// 2D coordinate in screen space
|
|
pub type Coordinate = Vec2;
|
|
|
|
/// Visibility flag for turtle
|
|
pub type Visibility = bool;
|
|
|
|
/// Speed of animations (higher = faster, >= 999 = instant)
|
|
pub type Speed = u32;
|
|
|
|
/// Color type re-export from macroquad
|
|
pub use macroquad::color::Color;
|