Fix turtle-lib API docs and invariant wording

Agent-Logs-Url: https://github.com/enaut/turtlers/sessions/5fb2f5ed-163f-4c2d-8180-1e96150e7e46

Co-authored-by: enaut <290005+enaut@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-21 20:08:40 +00:00 committed by GitHub
parent ece26bfe04
commit 2ac52ecc92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 6 deletions

View File

@ -349,6 +349,10 @@ impl TurtlePlan {
/// - `180°` points left (west)
/// - `270°` points down (south)
///
/// Internally, turtle heading is stored in radians in a Y-down render space.
/// This method converts from user-facing degrees (Y-up mental model) to that
/// internal representation.
///
/// # Examples
///
/// ```no_run
@ -366,6 +370,8 @@ impl TurtlePlan {
/// }
/// ```
pub fn set_heading<T: Into<Degrees>>(&mut self, heading: T) -> &mut Self {
// Convert user-facing turtle heading (degrees, Y-up mental model)
// to internal radians used by the render-space pipeline.
self.queue
.push(TurtleCommand::SetHeading(-heading.into().as_radians()));
self
@ -610,11 +616,14 @@ impl TurtlePlan {
/// The turtle moves in a straight line to the specified coordinates.
/// If the pen is down, a line is drawn. The turtle's heading is not changed.
///
/// Coordinates are in screen space:
/// Coordinates use turtle-style Cartesian space:
/// - `(0, 0)` is at the center
/// - Positive x goes right
/// - Positive y goes up
///
/// Internally, Macroquad uses Y-down screen coordinates; this command
/// performs the Y-axis conversion when executed.
///
/// # Examples
///
/// ```no_run
@ -677,7 +686,7 @@ impl TurtlePlan {
/// Resets the turtle to its default state.
///
/// This clears all drawings, clears the animation queue, and resets all turtle parameters:
/// This clears all drawings, clears active fill state, and resets turtle parameters:
/// - Position: (0, 0)
/// - Heading: 0° (facing right)
/// - Pen: down
@ -688,6 +697,8 @@ impl TurtlePlan {
/// - Shape: arrow
/// - Speed: default
///
/// Note: queued commands are not removed; `reset()` itself is a command in the queue.
///
/// # Examples
///
/// ```no_run

View File

@ -34,7 +34,8 @@ pub enum TurtleCommand {
// Position
Goto(Coordinate),
/// Heading stored as radians — already converted by the builder.
/// Heading stored as internal radians (Y-down render-space convention),
/// already converted by the builder from user-facing degrees.
SetHeading(Radians),
// Visibility

View File

@ -13,7 +13,11 @@ pub use length::Length;
/// Precision type for calculations
pub type Precision = f32;
/// 2D coordinate in screen space
/// 2D coordinate value (`Vec2`) used by turtle commands and state.
///
/// Coordinate orientation depends on API context:
/// - `go_to()` input uses turtle-style coordinates (Y+ is up)
/// - internal render-space state uses Macroquad-style Y-down coordinates
pub type Coordinate = Vec2;
/// Visibility flag for turtle

View File

@ -215,7 +215,7 @@ impl TurtleApp {
///
/// Speed is controlled by `SetSpeed` commands in the queue.
/// Use `set_speed()` on the turtle plan to set animation speed.
/// Speed >= 999 = instant mode, speed < 999 = animated mode.
/// Speed >= 1000 = instant mode, speed < 1000 = animated mode.
///
/// # Arguments
/// * `queue` - The command queue to execute
@ -228,7 +228,7 @@ impl TurtleApp {
///
/// Speed is controlled by `SetSpeed` commands in the queue.
/// Use `set_speed()` on the turtle plan to set animation speed.
/// Speed >= 999 = instant mode, speed < 999 = animated mode.
/// Speed >= 1000 = instant mode, speed < 1000 = animated mode.
///
/// # Arguments
/// * `turtle_id` - The ID of the turtle to control