12 releases

1.0.0-rc.3 Dec 11, 2019
1.0.0-rc.2 Aug 15, 2018
1.0.0-rc.1 Mar 10, 2018
1.0.0-alpha.8 Dec 22, 2017
0.1.0 Oct 28, 2015

#177 in Graphics APIs

Download history 39/week @ 2023-10-15 44/week @ 2023-10-22 67/week @ 2023-10-29 39/week @ 2023-11-05 29/week @ 2023-11-12 47/week @ 2023-11-19 86/week @ 2023-11-26 27/week @ 2023-12-03 53/week @ 2023-12-10 38/week @ 2023-12-17 63/week @ 2023-12-24 22/week @ 2023-12-31 50/week @ 2024-01-07 51/week @ 2024-01-14 65/week @ 2024-01-21 60/week @ 2024-01-28

231 downloads per month
Used in lindenmayer_graphic

MPL-2.0 license

2MB
4.5K SLoC

turtle

Crates.io Docs.rs Crates.io Crates.io Build Status Zulip Say Thanks!

Tweet your drawings to us on Twitter at @RustTurtle and follow us to see what is being created!

Create animated drawings with the Rust programming language. This crate is a tool for teaching programming by drawing pictures. Learning this way is fun and interesting for people of all ages!

The idea: You control a turtle with a pen tied to its tail. As it moves across the screen, it draws the path that it follows. You can use this to draw any picture you want just by moving the turtle across the screen.

turtle moving forward

Documentation

Example

As a simple example, you can draw a circle with only the following code:

use turtle::Turtle;

fn main() {
    let mut turtle = Turtle::new();

    for _ in 0..360 {
        // Move forward three steps
        turtle.forward(3.0);
        // Rotate to the right (clockwise) by 1 degree
        turtle.right(1.0);
    }
}

This will produce the following:

turtle drawing a circle

See the examples/ directory for more examples of how to use this crate.

Need help?

The following are some resources you can use to find help when you run into a problem. The links are listed in the order you should try each one, but feel free to come to the Turtle Zulip anytime if you are lost.

Contributing

See CONTRIBUTING.md for information about contributing to this project including how to build and test the project, submit new examples, report bugs, and more.

Inspiration & Goals

This crate is inspired by the Logo educational programming language. Many languages contain implementations of Logo's "turtle graphics". For example, the Python programming language comes with a built-in turtle module. This crate is largely inspired by the Python implementation, but uses Rust conventions and best practices to provide the best possible platform for learning Rust.

The goal of this crate is to be as easy to approach as possible and also provide the opportunity to explore Rust's most advanced features. We welcome contributions from anyone and everyone, including those that are new to the Rust programming language.

Dependencies

~1.3–4MB
~56K SLoC