turtle/
lib.rs

1//! Use the API Documentation below to learn about the various things you can do with this crate.
2//!
3//! **If this is your first time using Rust or using this crate, read the Guide on
4//! [turtle.rs](http://turtle.rs) to learn how to start.**
5//!
6//! * The [`Turtle` struct](struct.Turtle.html) - lists of all the various drawing commands that the
7//!   turtle supports
8//! * The [`Drawing` struct](struct.Drawing.html) - allows you to manipulate the title, size,
9//!   background and more of the drawing that you are creating
10//! * The [`color` module](color/index.html) - describes the different ways to create colors and
11//!   includes a list of the hundreds of predefined color names that you can use to easily set the
12//!   pen, fill, and background color of your drawings
13//!
14//! Note: Call [`turtle::start()`](fn.start.html) if you do not create a turtle with
15//! [`Turtle::new()`](struct.Turtle.html#method.new) right at the beginning of your program. Most
16//! programs will never need to call this function as it is called for you in
17//! [`Turtle::new()`](struct.Turtle.html#method.new).
18//!
19//! # Random Values
20//!
21//! See the [`rand` module](rand/index.html) for information about generating random colors, speeds,
22//! angles, and more which can be used in your programs to produce some interesting results!
23//!
24//! # Event Handling
25//!
26//! The [`Event` enum](event/enum.Event.html) documentation provides information about how you can
27//! create an event loop. This allows you to draw things in response to certain events like the
28//! mouse moving, keys being pressed, and more.
29//!
30//! The `Turtle` struct contains a few convenience methods so you can do some common event-related
31//! things without creating the entire event loop. For example, use
32//! [`wait_for_click()`](struct.Turtle.html#method.wait_for_click) to wait for the user to click
33//! anywhere on the screen before proceeding.
34//! # Unstable features
35//! Some parts of this library are unstable, such as maximizing and unmaximizing the window.
36//! You can explicitly opt-in to using those features with the `unstable` feature like so:
37//! 
38//! ```bash
39//! $ cargo build --features "unstable"
40//! ```
41//! 
42//! If you want to use this from inside your own crate, you will need to add this to your Cargo.toml
43//! ```toml
44//! [dependencies]
45//! turtle = { version = "...", features = ["unstable"] }
46//! ```
47
48#![doc(html_logo_url = "https://raw.githubusercontent.com/sunjay/turtle/master/docs/assets/images/turtle-logo-512.png")]
49#![cfg_attr(target_arch = "wasm32", crate_type = "cdylib")]
50
51#[cfg(all(test, not(feature = "test")))]
52compile_error!("Make sure you run tests with `cargo test --features test`");
53
54mod turtle_window;
55
56mod animation;
57#[cfg(not(target_arch = "wasm32"))]
58mod app;
59mod drawing;
60mod extensions;
61#[cfg(not(target_arch = "wasm32"))]
62mod messenger;
63mod point;
64mod query;
65mod radians;
66#[cfg(not(target_arch = "wasm32"))]
67mod renderer;
68mod renderer_process;
69#[cfg(not(target_arch = "wasm32"))]
70mod server;
71mod speed;
72mod state;
73mod timer;
74mod turtle;
75
76pub mod color;
77#[cfg(not(target_arch = "wasm32"))]
78pub mod event;
79#[cfg(target_arch = "wasm32")]
80mod event {
81    use serde::{Serialize, Deserialize};
82    #[derive(Debug, Clone, Serialize, Deserialize)]
83    pub enum Event {}
84}
85pub mod rand;
86
87pub use crate::color::Color;
88pub use crate::drawing::{Drawing, Size};
89pub use crate::event::Event;
90pub use crate::point::Point;
91#[cfg(target_arch = "wasm32")]
92pub use renderer_process::{alloc, dealloc, dealloc_str};
93pub use crate::speed::Speed;
94pub use crate::turtle::{Angle, Distance, Turtle};
95
96#[cfg(not(target_arch = "wasm32"))]
97pub use crate::server::start;
98#[cfg(target_arch = "wasm32")]
99pub fn start() {}