Crate turtle[][src]

Use the API Documentation below to learn about the various things you can do with this crate.

If this is your first time using Rust or using this crate, read the Guide on turtle.rs to learn how to start.

  • The Turtle struct - lists of all the various drawing commands that the turtle supports
  • The Drawing struct - allows you to manipulate the title, size, background and more of the drawing that you are creating
  • The color module - describes the different ways to create colors and includes a list of the hundreds of predefined color names that you can use to easily set the pen, fill, and background color of your drawings

Note: Call turtle::start() if you do not create a turtle with Turtle::new() right at the beginning of your program. Most programs will never need to call this function as it is called for you in Turtle::new().

Random Values

See the rand module for information about generating random colors, speeds, angles, and more which can be used in your programs to produce some interesting results!

Event Handling

The Event enum documentation provides information about how you can create an event loop. This allows you to draw things in response to certain events like the mouse moving, keys being pressed, and more.

The Turtle struct contains a few convenience methods so you can do some common event-related things without creating the entire event loop. For example, use wait_for_click() to wait for the user to click anywhere on the screen before proceeding.

Re-exports

pub use color::Color;
pub use event::Event;
pub use rand::random_range;

Modules

color

Color types and constants

event

Event handling (mouse, keyboard, controller, touch screen, etc.)

rand

Utilities for generating random values

Structs

Drawing

Represents the drawing that the turtle is creating

Point

A point in 2D space

Size

Represents a size

Speed

Represents both the movement and rotation speed of the turtle.

Turtle

A turtle with a pen attached to its tail

Functions

random

Generates a random value using the thread-local random number generator.

start

Start the turtle window in advance

Type Definitions

Angle

An angle value without a unit

Distance

Any distance value (positive or negative)