remove the bevy based turtle and rename turtle-lib-macroquad to turtle-lib

This commit is contained in:
Franz Dietrich 2025-10-12 20:31:05 +02:00
parent fe2beb01ed
commit 08a1802bd2
46 changed files with 100 additions and 510 deletions

View File

@ -2,19 +2,16 @@
## Project Overview
Rust workspace with turtle graphics implementations. **Primary focus: `turtle-lib-macroquad`** - lightweight library using Macroquad + Lyon for GPU-accelerated rendering.
Rust workspace with turtle graphics implementations. **Primary focus: `turtle-lib`** - lightweight library using Macroquad + Lyon for GPU-accelerated rendering.
### Workspace Structure
```
turtle/
├── turtle-lib-macroquad/ # MAIN LIBRARY - Macroquad + Lyon (focus here)
├── turtle-lib-macroquad-macros/ # Proc macro for turtle_main
├── turtle-lib/ # Legacy Bevy 0.17.1 implementation (maintenance only)
├── turtle-example/ # Legacy examples
└── turtle-ui/ # UI components
turtlers/
├── turtle-lib/ # MAIN LIBRARY - Macroquad + Lyon (focus here)
└── turtle-lib-macros/ # Proc macro for turtle_main
```
## Architecture (`turtle-lib-macroquad`)
## Architecture (`turtle-lib`)
### Core Design Pattern: Command Queue + Tweening
- **Builder API** (`TurtlePlan`) accumulates commands
@ -64,20 +61,20 @@ All drawing → Lyon → GPU mesh → Macroquad rendering
### Building & Testing
```bash
# Main library
cargo build --package turtle-lib-macroquad
cargo test --package turtle-lib-macroquad
cargo clippy --package turtle-lib-macroquad -- -Wclippy::pedantic \
cargo build --package turtle-lib
cargo test --package turtle-lib
cargo clippy --package turtle-lib -- -Wclippy::pedantic \
-Aclippy::cast_precision_loss -Aclippy::cast_sign_loss -Aclippy::cast_possible_truncation
# Run examples (15+ examples available)
cargo run --package turtle-lib-macroquad --example hello_turtle
cargo run --package turtle-lib-macroquad --example yinyang
cargo run --package turtle-lib-macroquad --example cheese_macro
cargo run --package turtle-lib --example hello_turtle
cargo run --package turtle-lib --example yinyang
cargo run --package turtle-lib --example cheese_macro
```
### Macro Crate
```bash
cargo build --package turtle-lib-macroquad-macros
cargo build --package turtle-lib-macros
```
### Code Quality Standards
@ -91,7 +88,7 @@ cargo build --package turtle-lib-macroquad-macros
### 1. The `turtle_main` Macro (PREFERRED for examples)
Simplest way to create turtle programs:
```rust
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Window Title")]
fn draw(turtle: &mut TurtlePlan) {
@ -102,7 +99,7 @@ fn draw(turtle: &mut TurtlePlan) {
Generates: window setup + render loop + quit handling (ESC/Q)
### 2. Import Convention
Only need: `use turtle_lib_macroquad::*;`
Only need: `use turtle_lib::*;`
- Re-exports: `vec2`, `RED/BLUE/GREEN/etc`, all turtle types
- No `use macroquad::prelude::*` needed (causes unused warnings)
@ -155,12 +152,12 @@ async fn main() {
### Adding Example
- Prefer `turtle_main` macro for simplicity
- Use only `use turtle_lib_macroquad::*;`
- Use only `use turtle_lib::*;`
- Keep examples focused (one concept each)
- See `examples/hello_turtle.rs` for minimal template
### Debugging Lyon Issues
- Enable tracing: `RUST_LOG=turtle_lib_macroquad=debug cargo run`
- Enable tracing: `RUST_LOG=turtle_lib=debug cargo run`
- Check `tessellation.rs` for Lyon API usage
- EvenOdd fill rule: holes must have opposite winding
@ -182,14 +179,13 @@ async fn main() {
- Don't add `use macroquad::prelude::*` in examples when not required
- Don't manually triangulate - use Lyon functions
- Don't add commands for Forward/Backward separately (use Move)
- Don't modify `turtle-lib` (Bevy) unless specifically needed
- Don't create summary/comparison docs unless requested
## Key Documentation Files
- `README.md` - Main API docs
- `turtle-lib-macroquad/README.md` - Library-specific docs
- `turtle-lib-macroquad-macros/README.md` - Macro docs
- `turtle-lib/README.md` - Library-specific docs
- `turtle-lib-macros/README.md` - Macro docs
## Response Style

View File

@ -1,12 +1,7 @@
[workspace]
resolver = "2"
members = [
"turtle-lib",
"turtle-example",
"turtle-lib-macroquad",
"turtle-lib-macroquad-macros",
]
members = ["turtle-lib", "turtle-lib-macros"]
[workspace.dependencies]

View File

@ -22,7 +22,7 @@ A modern turtle graphics library for Rust built on [Macroquad](https://macroquad
```rust
use macroquad::prelude::*;
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[macroquad::main("Turtle")]
async fn main() {
@ -169,19 +169,18 @@ Control verbosity with the `RUST_LOG` environment variable:
```bash
# Show debug output
RUST_LOG=turtle_lib_macroquad=debug cargo run
RUST_LOG=turtle_lib=debug cargo run
# Very verbose trace output
RUST_LOG=turtle_lib_macroquad=trace cargo run
RUST_LOG=turtle_lib=trace cargo run
```
**See the complete example**: [`examples/logging_example.rs`](turtle-lib-macroquad/examples/logging_example.rs) demonstrates initialization, log levels, filtering, and example output.
**See the complete example**: [`examples/logging_example.rs`](turtle-lib/examples/logging_example.rs) demonstrates initialization, log levels, filtering, and example output.
## Examples
Run examples with:
```bash
# From turtle-lib-macroquad directory
cargo run --example square
cargo run --example koch
cargo run --example shapes
@ -191,12 +190,7 @@ cargo run --example nikolaus
# Logging example - shows how to enable debug output
cargo run --example logging_example
RUST_LOG=turtle_lib_macroquad=debug cargo run --example logging_example
# Lyon proof-of-concept examples
cargo run --package turtle-lyon-poc --example yinyang --release
cargo run --package turtle-lyon-poc --example basic_shapes --release
cargo run --package turtle-lyon-poc --example fill_comparison --release
RUST_LOG=turtle_lib=debug cargo run --example logging_example
```
### Available Examples
@ -275,7 +269,7 @@ plan.end_fill(); // Auto-detects holes and fills correctly
### Module Structure
```
turtle-lib-macroquad/src/
turtle-lib/src/
├── lib.rs - Public API and TurtleApp
├── state.rs - TurtleState and TurtleWorld
├── commands.rs - TurtleCommand enum (consolidated commands)
@ -314,14 +308,11 @@ This design eliminates ~250 lines of duplicate code while maintaining the same u
## Workspace Structure
```
turtle/
├── turtle-lib-macroquad/ - Main library (Macroquad + Lyon)
├── turtle-lib/ - Legacy Bevy-based implementation
└── turtle-example/ - Legacy examples
turtlers/
├── turtle-lib/ - Main library (Macroquad + Lyon)
└── turtle-lib-macros/ - Procedural macros (turtle_main)
```
The `turtle-lib-macroquad` package is the current and future focus of development.
## Building and Running
```bash
@ -329,13 +320,10 @@ The `turtle-lib-macroquad` package is the current and future focus of developmen
cargo check
# Run specific example
cargo run --package turtle-lib-macroquad --example yinyang
cargo run --example yinyang
# Build release version
cargo build --release
# Run Lyon POC examples to see future rendering
cargo run --package turtle-lyon-poc --example yinyang --release
```
## Development Status

View File

@ -1,14 +0,0 @@
[package]
name = "turtle-example"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = { workspace = true, features = ["wayland"] }
bevy_prototype_lyon = { workspace = true }
num-traits = { workspace = true }
rand = { workspace = true }
turtle-lib = { path = "../turtle-lib" }

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,18 +0,0 @@
# turtle-example
**⚠️ LEGACY PACKAGE - Bevy-based implementation**
This package contains the original Bevy-based turtle implementation.
**For current development, see [turtle-lib-macroquad](../turtle-lib-macroquad/).**
**See the [main README](../README.md) for the active project.**
## Status
This package is no longer actively developed. The project has moved to a Macroquad + Lyon architecture for:
- Faster compilation times
- Simpler codebase
- Better rendering quality
Examples here are kept for reference only.

View File

@ -1,29 +0,0 @@
use bevy::prelude::*;
use turtle_lib::builders::{DirectionalMovement, StopLine, Turnable};
use turtle_lib::{get_a_turtle, TurtlePlugin};
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
#[derive(Component, Reflect)]
struct Egon {}
fn main() {
App::new()
.add_plugins(TurtlePlugin)
.add_systems(Startup, setup)
//.add_systems(Update, plan)
.add_plugins(LogDiagnosticsPlugin::default())
.add_plugins(FrameTimeDiagnosticsPlugin::default())
.run();
}
fn setup(mut commands: Commands) {
let mut turtle = get_a_turtle();
turtle.set_speed(1);
// NOTE: pen_up() consumes self, which is why this example is incomplete
// TODO: Fix the builder API to work with the deref pattern
// let mt = turtle.pen_up();
commands.spawn((turtle, Egon {}));
}

View File

@ -1,43 +0,0 @@
use bevy::prelude::*;
use turtle_lib::builders::{DirectionalMovement, Turnable};
use turtle_lib::turtle_bundle::AnimatedTurtle;
use turtle_lib::{get_a_turtle, TurtlePlugin};
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
#[derive(Component, Reflect)]
struct Egon {}
fn main() {
App::new()
.add_plugins(TurtlePlugin)
.add_systems(Startup, setup)
//.add_systems(Update, plan)
.add_plugins(LogDiagnosticsPlugin::default())
.add_plugins(FrameTimeDiagnosticsPlugin::default())
.run();
}
fn setup(mut commands: Commands) {
let mut turtle = get_a_turtle();
turtle.set_speed(1);
for _x in 0..3 {
koch(4, &mut turtle);
turtle.right(120);
}
commands.spawn((turtle, Egon {}));
}
fn koch(depth: u32, turtle: &mut AnimatedTurtle) {
if depth == 0 {
turtle.forward(10);
} else {
koch(depth - 1, turtle);
turtle.left(60);
koch(depth - 1, turtle);
turtle.right(120);
koch(depth - 1, turtle);
turtle.left(60);
koch(depth - 1, turtle);
}
}

View File

@ -1,73 +0,0 @@
use bevy::prelude::*;
use turtle_lib::builders::{DirectionalMovement, Turnable};
use turtle_lib::turtle_bundle::AnimatedTurtle;
use turtle_lib::{get_a_turtle, TurtlePlugin};
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
#[derive(Component, Reflect)]
struct Egon {}
fn main() {
App::new()
.add_plugins(TurtlePlugin)
.add_systems(Startup, setup)
//.add_systems(Update, plan)
.add_plugins(LogDiagnosticsPlugin::default())
.add_plugins(FrameTimeDiagnosticsPlugin::default())
.run();
}
fn setup(mut commands: Commands) {
let mut turtle = get_a_turtle();
turtle.set_speed(500);
stern(&mut turtle);
commands.spawn((turtle, Egon {}));
}
fn stern(turtle: &mut AnimatedTurtle) {
// Draw the roof of the house
turtle.left(45);
turtle.forward(70);
turtle.right(90);
turtle.forward(70);
turtle.left(45);
// Draw the sides of the house
turtle.left(90);
turtle.forward(100);
turtle.left(90);
turtle.forward(50);
turtle.left(90);
turtle.forward(100);
turtle.left(90);
turtle.forward(50);
// Draw the door of the house
turtle.left(90);
turtle.forward(25);
turtle.right(90);
turtle.forward(20);
turtle.right(90);
turtle.forward(25);
turtle.left(90);
turtle.forward(50);
// Draw the chimney of the house
turtle.left(90);
turtle.forward(25);
turtle.right(90);
turtle.forward(10);
turtle.right(90);
turtle.forward(25);
turtle.left(90);
turtle.forward(10);
turtle.left(90);
turtle.forward(10);
turtle.right(90);
turtle.forward(25);
turtle.left(90);
turtle.forward(10);
turtle.left(90);
turtle.forward(10);
}

View File

@ -1,36 +0,0 @@
use bevy::prelude::*;
use turtle_lib::builders::{CurvedMovement, DirectionalMovement};
use turtle_lib::turtle_bundle::AnimatedTurtle;
use turtle_lib::{get_a_turtle, TurtlePlugin};
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
#[derive(Component, Reflect)]
struct Egon {}
fn main() {
App::new()
.add_plugins(TurtlePlugin)
.add_systems(Startup, setup)
//.add_systems(Update, plan)
.add_plugins(LogDiagnosticsPlugin::default())
.add_plugins(FrameTimeDiagnosticsPlugin::default())
.run();
}
fn setup(mut commands: Commands) {
let mut turtle = get_a_turtle();
turtle.set_speed(1000);
stern(&mut turtle);
commands.spawn((turtle, Egon {}));
}
fn stern(turtle: &mut AnimatedTurtle) {
for _ in 0..5 {
turtle.forward(200);
turtle.circle(10, 72);
turtle.circle_right(5, 360);
turtle.circle(10, 72);
}
}

View File

@ -1,130 +0,0 @@
use bevy::prelude::*;
// Note: bevy_inspector_egui and bevy_tweening are not yet fully compatible with Bevy 0.17
// This example is disabled until they are updated
// use bevy_inspector_egui::prelude::*;
// use bevy_tweening::{lens::*, *};
fn main() {
App::default()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "TransformPositionLens".to_string(),
resolution: (1400, 600).into(),
present_mode: bevy::window::PresentMode::Fifo, // vsync
..default()
}),
..default()
}))
// .add_systems(Update, bevy::window::close_on_esc)
// .add_plugins(TweeningPlugin)
.add_systems(Startup, setup)
// .add_systems(Update, update_animation_speed)
.register_type::<Options>()
.run();
}
#[derive(Copy, Clone, PartialEq, Reflect, Resource)]
struct Options {
speed: f32,
}
impl Default for Options {
fn default() -> Self {
Self { speed: 1. }
}
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2d);
// NOTE: This example is disabled because bevy_tweening is not yet compatible with Bevy 0.17
// Once bevy_tweening is updated, uncomment the code below
/*
let size = 25.;
let spacing = 1.5;
let screen_x = 570.;
let screen_y = 150.;
let mut x = -screen_x;
for ease_function in &[
EaseFunction::QuadraticIn,
EaseFunction::QuadraticOut,
EaseFunction::QuadraticInOut,
EaseFunction::CubicIn,
EaseFunction::CubicOut,
EaseFunction::CubicInOut,
EaseFunction::QuarticIn,
EaseFunction::QuarticOut,
EaseFunction::QuarticInOut,
EaseFunction::QuinticIn,
EaseFunction::QuinticOut,
EaseFunction::QuinticInOut,
EaseFunction::SineIn,
EaseFunction::SineOut,
EaseFunction::SineInOut,
EaseFunction::CircularIn,
EaseFunction::CircularOut,
EaseFunction::CircularInOut,
EaseFunction::ExponentialIn,
EaseFunction::ExponentialOut,
EaseFunction::ExponentialInOut,
EaseFunction::ElasticIn,
EaseFunction::ElasticOut,
EaseFunction::ElasticInOut,
EaseFunction::BackIn,
EaseFunction::BackOut,
EaseFunction::BackInOut,
EaseFunction::BounceIn,
EaseFunction::BounceOut,
EaseFunction::BounceInOut,
] {
let tween = Tween::new(
*ease_function,
std::time::Duration::from_secs(1),
TransformPositionLens {
start: Vec3::new(x, screen_y, 0.),
end: Vec3::new(x, -screen_y, 0.),
},
)
.then(
Tween::new(
EaseFunction::QuadraticInOut,
std::time::Duration::from_millis(200),
TransformRotateZLens {
start: 0.05,
end: -0.05,
},
)
.with_repeat_strategy(bevy_tweening::RepeatStrategy::MirroredRepeat)
.with_repeat_count(RepeatCount::Infinite),
);
commands.spawn((
Sprite {
color: Color::srgb(1.0, 0.0, 0.0),
custom_size: Some(Vec2::new(size, size)),
..default()
},
Animator::new(tween),
));
x += size * spacing;
}
*/
}
fn update_animation_speed(_options: Res<Options> /*, mut animators: Query<&mut Animator<Transform>>*/) {
// NOTE: This function is disabled because bevy_tweening is not yet compatible with Bevy 0.17
/*
if !options.is_changed() {
return;
}
for mut animator in animators.iter_mut() {
animator.set_speed(options.speed);
}
*/
}

View File

@ -1,37 +0,0 @@
use bevy::prelude::*;
use turtle_lib::builders::{CurvedMovement, DirectionalMovement, Turnable};
use turtle_lib::{get_a_turtle, TurtlePlugin};
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
#[derive(Component, Reflect)]
struct Egon {}
fn main() {
App::new()
.add_plugins(TurtlePlugin)
.add_systems(Startup, setup)
//.add_system(plan)
.add_plugins(LogDiagnosticsPlugin::default())
.add_plugins(FrameTimeDiagnosticsPlugin::default())
.run();
}
fn setup(mut commands: Commands) {
let mut turtle = get_a_turtle();
turtle.set_speed(0);
turtle.circle(50, 90);
turtle.circle_right(50, 180);
turtle.circle(50, 90);
for x in 0..1999 {
turtle.forward(x);
turtle.right(45);
turtle.forward(30);
turtle.left(90 + x);
turtle.forward(30);
turtle.right(45);
turtle.forward(x);
turtle.left(91);
}
commands.spawn((turtle, Egon {}));
}

View File

@ -1,5 +1,5 @@
[package]
name = "turtle-lib-macroquad-macros"
name = "turtle-lib-macros"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

View File

@ -1,6 +1,6 @@
# turtle-lib-macroquad-macros
# turtle-lib-macros
Procedural macros for `turtle-lib-macroquad`.
Procedural macros for `turtle-lib`.
## `turtle_main` Macro
@ -16,7 +16,7 @@ The `turtle_main` macro simplifies creating turtle graphics programs by automati
```rust
use macroquad::prelude::*;
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("My Drawing")]
fn my_drawing(turtle: &mut TurtlePlan) {
@ -31,7 +31,7 @@ fn my_drawing(turtle: &mut TurtlePlan) {
```rust
use macroquad::prelude::*;
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("My Drawing")]
fn my_drawing() {

View File

@ -1,4 +1,4 @@
//! Procedural macros for turtle-lib-macroquad
//! Procedural macros for turtle-lib
//!
//! This crate provides the `turtle_main` procedural macro that simplifies
//! creating turtle graphics programs by automatically setting up the
@ -20,11 +20,11 @@ use syn::{parse_macro_input, ItemFn};
/// # Example
///
/// ```no_run
/// use turtle_lib_macroquad::*;
/// use turtle_lib::*;
///
/// #[turtle_main("My Turtle Drawing")]
/// fn my_drawing(turtle: &mut TurtlePlan) {
/// // Use colors from turtle_lib_macroquad (re-exported from macroquad)
/// // Use colors from turtle_lib (re-exported from macroquad)
/// turtle.set_pen_color(RED);
/// turtle.forward(100.0);
/// turtle.right(90.0);
@ -32,11 +32,11 @@ use syn::{parse_macro_input, ItemFn};
/// }
/// ```
///
/// If you need macroquad types not re-exported by turtle_lib_macroquad:
/// If you need macroquad types not re-exported by turtle_lib:
///
/// ```no_run
/// use macroquad::prelude::SKYBLUE; // Import specific items
/// use turtle_lib_macroquad::*;
/// use turtle_lib::*;
///
/// #[turtle_main("My Drawing")]
/// fn my_drawing(turtle: &mut TurtlePlan) {
@ -49,7 +49,7 @@ use syn::{parse_macro_input, ItemFn};
///
/// ```no_run
/// use macroquad::prelude::*;
/// use turtle_lib_macroquad::*;
/// use turtle_lib::*;
///
/// #[macroquad::main("My Turtle Drawing")]
/// async fn main() {
@ -102,12 +102,12 @@ pub fn turtle_main(args: TokenStream, input: TokenStream) -> TokenStream {
quote! {
#[macroquad::main(#window_title)]
async fn main() {
let mut turtle = turtle_lib_macroquad::create_turtle();
let mut turtle = turtle_lib::create_turtle();
// Call the user's function with the turtle
#fn_name(&mut turtle);
let mut app = turtle_lib_macroquad::TurtleApp::new()
let mut app = turtle_lib::TurtleApp::new()
.with_commands(turtle.build());
loop {
@ -132,19 +132,19 @@ pub fn turtle_main(args: TokenStream, input: TokenStream) -> TokenStream {
}
}
fn #fn_name(turtle: &mut turtle_lib_macroquad::TurtlePlan) #fn_block
fn #fn_name(turtle: &mut turtle_lib::TurtlePlan) #fn_block
}
} else {
// Function takes no parameters - inline the code
quote! {
#[macroquad::main(#window_title)]
async fn main() {
let mut turtle = turtle_lib_macroquad::create_turtle();
let mut turtle = turtle_lib::create_turtle();
// Inline the user's code
#fn_block
let mut app = turtle_lib_macroquad::TurtleApp::new()
let mut app = turtle_lib::TurtleApp::new()
.with_commands(turtle.build());
loop {

View File

@ -1,5 +1,5 @@
[package]
name = "turtle-lib-macroquad"
name = "turtle-lib"
version = "0.2.0"
edition = "2021"
license = "MIT OR Apache-2.0"
@ -9,7 +9,7 @@ macroquad = "0.4"
tween = "2.1.0"
lyon = "1.0"
tracing = { version = "0.1", features = ["log"], default-features = false }
turtle-lib-macroquad-macros = { path = "../turtle-lib-macroquad-macros" }
turtle-lib-macros = { path = "../turtle-lib-macros" }
[dev-dependencies]
# For examples and testing

View File

@ -1,4 +1,4 @@
# turtle-lib-macroquad
# turtle-lib
The main turtle graphics library built on Macroquad with Lyon tessellation.
@ -30,7 +30,7 @@ The easiest way to create turtle programs is with the `turtle_main` macro:
```rust
use macroquad::prelude::*;
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("My First Drawing")]
fn my_drawing(turtle: &mut TurtlePlan) {
@ -53,7 +53,7 @@ For more control over the application loop:
```rust
use macroquad::prelude::*;
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[macroquad::main("Turtle")]
async fn main() {

View File

@ -8,7 +8,7 @@
//! Lyon's EvenOdd fill rule automatically creates holes where contours overlap!
use macroquad::prelude::*;
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[macroquad::main("Cheese with Holes")]
async fn main() {

View File

@ -3,7 +3,7 @@
//! This is a simplified version of cheese.rs that demonstrates how the
//! turtle_main macro reduces boilerplate code.
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Cheese with Holes - Using Macro")]
fn draw_cheese(turtle: &mut TurtlePlan) {

View File

@ -1,6 +1,6 @@
//! Test circle_left and circle_right commands
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Circle Test")]
fn draw(turtle: &mut TurtlePlan) {

View File

@ -35,7 +35,7 @@
//! function, passing the direction of the turn for this fold as an angle
//! (+90 for a right turn, -90 for a left turn).
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Dragon Curve")]
fn draw_dragon(turtle: &mut TurtlePlan) {

View File

@ -3,7 +3,7 @@
//! This example uses manual setup to demonstrate custom window size and UI elements.
use macroquad::{miniquad::window::set_window_size, prelude::*};
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[macroquad::main("Advanced Fill Demo")]
async fn main() {

View File

@ -2,7 +2,7 @@
//!
//! This is the simplest possible turtle program using the macro.
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Hello Turtle")]
fn hello() {

View File

@ -1,6 +1,6 @@
//! Koch snowflake fractal example
use turtle_lib_macroquad::*;
use turtle_lib::*;
fn koch(depth: u32, turtle: &mut TurtlePlan, distance: f32) {
if depth == 0 {

View File

@ -4,24 +4,24 @@
//! You can control the log level using the `RUST_LOG` environment variable:
//!
//! ```bash
//! # Show all debug output from turtle-lib-macroquad
//! RUST_LOG=turtle_lib_macroquad=debug cargo run --example logging_example
//! # Show all debug output from turtle-lib
//! RUST_LOG=turtle_lib=debug cargo run --example logging_example
//!
//! # Show only warnings and errors
//! RUST_LOG=turtle_lib_macroquad=warn cargo run --example logging_example
//! RUST_LOG=turtle_lib=warn cargo run --example logging_example
//!
//! # Show trace-level output (very verbose, includes all vertices)
//! RUST_LOG=turtle_lib_macroquad=trace cargo run --example logging_example
//! RUST_LOG=turtle_lib=trace cargo run --example logging_example
//!
//! # Show debug output from specific modules
//! RUST_LOG=turtle_lib_macroquad::tessellation=debug cargo run --example logging_example
//! RUST_LOG=turtle_lib_macroquad::execution=debug cargo run --example logging_example
//! RUST_LOG=turtle_lib::tessellation=debug cargo run --example logging_example
//! RUST_LOG=turtle_lib::execution=debug cargo run --example logging_example
//! ```
//!
//! Note: This example uses manual setup to demonstrate custom initialization logic.
use macroquad::prelude::*;
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[macroquad::main("Turtle Logging Example")]
async fn main() {
@ -31,7 +31,7 @@ async fn main() {
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
// Default to showing info-level logs if RUST_LOG is not set
tracing_subscriber::EnvFilter::new("turtle_lib_macroquad=info")
tracing_subscriber::EnvFilter::new("turtle_lib=info")
}),
)
.with_target(true) // Show which module the log came from
@ -42,7 +42,7 @@ async fn main() {
tracing::info!("Starting turtle graphics example with logging enabled");
tracing::info!(
"Try running with: RUST_LOG=turtle_lib_macroquad=debug cargo run --example logging_example"
"Try running with: RUST_LOG=turtle_lib=debug cargo run --example logging_example"
);
// Create a turtle plan with fill operations to see detailed logging

View File

@ -3,7 +3,7 @@
//! This example shows how the turtle_main macro simplifies turtle programs
//! by automatically handling window setup, turtle creation, and the render loop.
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Macro Demo - Simple Square")]
fn draw_square(turtle: &mut TurtlePlan) {

View File

@ -3,7 +3,7 @@
//! This example shows that you can write your turtle code directly
//! in the function body without taking a turtle parameter.
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Macro Demo - Inline Spiral")]
fn draw_spiral() {

View File

@ -1,6 +1,6 @@
//! Nikolaus example - draws a house-like figure
use turtle_lib_macroquad::*;
use turtle_lib::*;
fn nikolausquadrat(turtle: &mut TurtlePlan, groesse: f32) {
turtle.forward(groesse);

View File

@ -1,6 +1,6 @@
//! Example demonstrating different turtle shapes
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Turtle Shapes")]
fn draw(turtle: &mut TurtlePlan) {

View File

@ -19,7 +19,7 @@
//! size: the triangle will stay correctly sized and positioned automatically.
use macroquad::window::{screen_height, screen_width};
use turtle_lib_macroquad::*;
use turtle_lib::*;
/// The number of levels to draw following the recursive procedure.
const LEVELS: u8 = 9;

View File

@ -1,6 +1,6 @@
//! Star pattern example demonstrating complex turtle patterns
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Star Pattern")]
fn draw(turtle: &mut TurtlePlan) {

View File

@ -3,7 +3,7 @@
//! This example draws "1.0.0" with decorative background lines and filled shapes.
//! Ported from the original sunjay/turtle example.
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Version 1.0.0")]
fn draw_version(turtle: &mut TurtlePlan) {

View File

@ -1,6 +1,6 @@
//! Yin-Yang symbol example demonstrating multi-contour fills
use turtle_lib_macroquad::*;
use turtle_lib::*;
#[turtle_main("Yin-Yang")]
fn draw(turtle: &mut TurtlePlan) {

View File

@ -20,7 +20,7 @@ pub trait DirectionalMovement: WithCommands {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Forward Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -48,7 +48,7 @@ pub trait DirectionalMovement: WithCommands {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Backward Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -79,7 +79,7 @@ pub trait Turnable: WithCommands {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Left Turn Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -106,7 +106,7 @@ pub trait Turnable: WithCommands {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Right Turn Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -142,7 +142,7 @@ pub trait CurvedMovement: WithCommands {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Circle Left Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -187,7 +187,7 @@ pub trait CurvedMovement: WithCommands {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Circle Right Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -235,7 +235,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// use turtle_lib_macroquad::*;
/// use turtle_lib::*;
/// use macroquad::prelude::*;
///
/// #[macroquad::main("Manual Setup")]
@ -276,7 +276,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Speed Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -302,7 +302,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Pen Color Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -326,7 +326,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Pen Width Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -354,7 +354,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Heading Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -380,7 +380,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Pen Up/Down Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -414,7 +414,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Pen Down Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -437,7 +437,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Hide Turtle Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -460,7 +460,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Show Turtle Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -482,7 +482,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Shape Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -502,7 +502,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Shape Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -529,7 +529,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Fill Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -562,7 +562,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("End Fill Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -588,7 +588,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Fill Color Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -619,7 +619,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```no_run
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// #[turtle_main("Goto Example")]
/// fn draw(turtle: &mut TurtlePlan) {
@ -643,7 +643,7 @@ impl TurtlePlan {
/// # Examples
///
/// ```
/// # use turtle_lib_macroquad::*;
/// # use turtle_lib::*;
/// #
/// let mut turtle = TurtlePlan::new();
/// turtle.forward(100.0).right(90.0).forward(100.0);

View File

@ -9,7 +9,7 @@
//!
//! ```no_run
//! use macroquad::prelude::*;
//! use turtle_lib_macroquad::*;
//! use turtle_lib::*;
//!
//! #[turtle_main("My Drawing")]
//! fn draw(turtle: &mut TurtlePlan) {
@ -28,7 +28,7 @@
//!
//! ```no_run
//! use macroquad::prelude::*;
//! use turtle_lib_macroquad::*;
//! use turtle_lib::*;
//!
//! #[macroquad::main("Turtle")]
//! async fn main() {
@ -66,7 +66,7 @@ pub use state::{DrawCommand, TurtleState, TurtleWorld};
pub use tweening::TweenController;
// Re-export the turtle_main macro
pub use turtle_lib_macroquad_macros::turtle_main;
pub use turtle_lib_macros::turtle_main;
// Re-export common macroquad types and colors for convenience
pub use macroquad::prelude::{
@ -225,7 +225,7 @@ impl Default for TurtleApp {
///
/// # Example
/// ```
/// use turtle_lib_macroquad::*;
/// use turtle_lib::*;
///
/// let mut turtle = create_turtle();
/// turtle.forward(100.0).right(90.0).forward(50.0);