rename create_turtle{,_plan}

This commit is contained in:
Franz Dietrich 2025-10-17 18:38:44 +02:00
parent 3509060390
commit fcca1a2db4
6 changed files with 12 additions and 18 deletions

View File

@ -53,7 +53,7 @@ use syn::{parse_macro_input, ItemFn};
/// ///
/// #[macroquad::main("My Turtle Drawing")] /// #[macroquad::main("My Turtle Drawing")]
/// async fn main() { /// async fn main() {
/// let mut turtle = create_turtle(); /// let mut turtle = create_turtle_plan();
/// ///
/// // Your drawing code here /// // Your drawing code here
/// turtle.set_pen_color(RED); /// turtle.set_pen_color(RED);
@ -102,7 +102,7 @@ pub fn turtle_main(args: TokenStream, input: TokenStream) -> TokenStream {
quote! { quote! {
#[macroquad::main(#window_title)] #[macroquad::main(#window_title)]
async fn main() { async fn main() {
let mut turtle = turtle_lib::create_turtle(); let mut turtle = turtle_lib::create_turtle_plan();
// Call the user's function with the turtle // Call the user's function with the turtle
#fn_name(&mut turtle); #fn_name(&mut turtle);
@ -139,7 +139,7 @@ pub fn turtle_main(args: TokenStream, input: TokenStream) -> TokenStream {
quote! { quote! {
#[macroquad::main(#window_title)] #[macroquad::main(#window_title)]
async fn main() { async fn main() {
let mut turtle = turtle_lib::create_turtle(); let mut turtle = turtle_lib::create_turtle_plan();
// Inline the user's code // Inline the user's code
#fn_block #fn_block

View File

@ -12,7 +12,7 @@ use turtle_lib::*;
#[macroquad::main("Cheese with Holes")] #[macroquad::main("Cheese with Holes")]
async fn main() { async fn main() {
let mut turtle = create_turtle(); let mut turtle = create_turtle_plan();
// Set fill color to yellow (cheese color!) // Set fill color to yellow (cheese color!)
turtle.set_fill_color(YELLOW); turtle.set_fill_color(YELLOW);

View File

@ -8,7 +8,7 @@ use turtle_lib::*;
#[macroquad::main("Advanced Fill Demo")] #[macroquad::main("Advanced Fill Demo")]
async fn main() { async fn main() {
set_window_size(2000, 1900); set_window_size(2000, 1900);
let mut t = create_turtle(); let mut t = create_turtle_plan();
// Example 1: Star shape (concave polygon) // Example 1: Star shape (concave polygon)
t.pen_up(); t.pen_up();

View File

@ -46,7 +46,7 @@ async fn main() {
); );
// Create a turtle plan with fill operations to see detailed logging // Create a turtle plan with fill operations to see detailed logging
let mut t = create_turtle(); let mut t = create_turtle_plan();
t.set_speed(900); t.set_speed(900);
// Draw a yin-yang symbol with fills (generates lots of debug output) // Draw a yin-yang symbol with fills (generates lots of debug output)

View File

@ -30,7 +30,7 @@ async fn main() {
set_window_size(1900, 1000); set_window_size(1900, 1000);
// Turtle 0 (default turtle) - Draw a spiral (red) // Turtle 0 (default turtle) - Draw a spiral (red)
let mut turtle0 = create_turtle(); let mut turtle0 = create_turtle_plan();
turtle0.right(45.0); turtle0.right(45.0);
turtle0.set_speed(1900.0); turtle0.set_speed(1900.0);
turtle0.set_pen_color(RED); turtle0.set_pen_color(RED);
@ -48,7 +48,7 @@ async fn main() {
// Turtle 1 - Draw a square (blue) // Turtle 1 - Draw a square (blue)
let turtle1_id = app.add_turtle(); let turtle1_id = app.add_turtle();
let mut turtle1 = create_turtle(); let mut turtle1 = create_turtle_plan();
turtle1.set_speed(1900.0); turtle1.set_speed(1900.0);
turtle1.pen_up(); turtle1.pen_up();
turtle1.go_to(vec2(-200.0, 0.0)); turtle1.go_to(vec2(-200.0, 0.0));
@ -64,7 +64,7 @@ async fn main() {
// Turtle 2 - Draw a hexagon (green) // Turtle 2 - Draw a hexagon (green)
let turtle2_id = app.add_turtle(); let turtle2_id = app.add_turtle();
let mut turtle2 = create_turtle(); let mut turtle2 = create_turtle_plan();
turtle2.set_speed(150.0); turtle2.set_speed(150.0);
turtle2.pen_up(); turtle2.pen_up();
turtle2.go_to(vec2(200.0, 0.0)); turtle2.go_to(vec2(200.0, 0.0));
@ -77,7 +77,7 @@ async fn main() {
// Turtle 3 - Draw a star (yellow) // Turtle 3 - Draw a star (yellow)
let turtle3_id = app.add_turtle(); let turtle3_id = app.add_turtle();
let mut turtle3 = create_turtle(); let mut turtle3 = create_turtle_plan();
turtle3.set_fill_color(ORANGE); turtle3.set_fill_color(ORANGE);
turtle3.begin_fill(); turtle3.begin_fill();
turtle3.set_speed(150.0); turtle3.set_speed(150.0);
@ -92,7 +92,7 @@ async fn main() {
turtle3.end_fill(); turtle3.end_fill();
// Turtle 4 - Draw a filled circle (purple) // Turtle 4 - Draw a filled circle (purple)
let turtle4_id = app.add_turtle(); let turtle4_id = app.add_turtle();
let mut turtle4 = create_turtle(); let mut turtle4 = create_turtle_plan();
turtle4.set_speed(150.0); turtle4.set_speed(150.0);
turtle4.pen_up(); turtle4.pen_up();
turtle4.go_to(vec2(0.0, -150.0)); turtle4.go_to(vec2(0.0, -150.0));

View File

@ -271,12 +271,6 @@ impl Default for TurtleApp {
/// let commands = turtle.build(); /// let commands = turtle.build();
/// ``` /// ```
#[must_use] #[must_use]
pub fn create_turtle() -> TurtlePlan { pub fn create_turtle_plan() -> TurtlePlan {
TurtlePlan::new() TurtlePlan::new()
} }
/// Convenience function to get a turtle plan (alias for `create_turtle`)
#[must_use]
pub fn get_a_turtle() -> TurtlePlan {
create_turtle()
}