Struct rurtle::turtle::Turtle
[−]
[src]
pub struct Turtle { // some fields omitted }
The Turtle
struct is the thing that actually provides the methods to walk
on the screen
Methods
impl Turtle
fn new(screen: TurtleScreen) -> Turtle
Construct a new Turtle. Moves the TurtleScreen.
fn get_screen(&mut self) -> &mut TurtleScreen
Return a reference to the underlaying TurtleScreen
object
fn clear(&mut self)
Clear the screen. Note that this only removes the drawn lines, it does not change the turtle's position or orientation.
fn forward(&mut self, length: f32)
Move the turtle forward by the given length
fn backward(&mut self, length: f32)
Move the turtle backward by the given length
fn left(&mut self, deg: f32)
Turn the turtle left
fn right(&mut self, deg: f32)
Turn the turtle right
fn pen_up(&mut self)
"Lifts" the pen so that no lines are drawn anymore
fn pen_down(&mut self)
Sinks the pen again so that lines are drawn
fn set_color(&mut self, red: f32, green: f32, blue: f32)
Set the turtle's color. New lines will be drawn using that color but
existing lines will remain in their color. red
, green
and blue
are
given as floats in the range [0; 1], where 0 means nothing and 1 full
(like #FF in HTML).
fn set_background_color(&mut self, red: f32, green: f32, blue: f32)
Set the background color of the screen.
fn teleport(&mut self, x: f32, y: f32)
Directly move the turtle to the given point without changing the direction. Draws a line if the pen is down. Note that the origin (0, 0) is in the center of the screen with positive coordinates being right/top and negative ones left/down.
fn set_orientation(&mut self, deg: f32)
Set the turtle's orientation in degrees with 0 being faced north and positive degrees counting counter-clockwise.
fn home(&mut self)
Move the turtle to the origin and set its orientation to 0
fn get_orientation(&self) -> f32
Return the turtle's orientation
fn get_position(&self) -> (f32, f32)
Return the turtle's position
fn hide(&mut self)
Hide the turtle so it won't be drawn on the screen
fn show(&mut self)
Show the turtle again after it has been hidden
fn is_hidden(&self) -> bool
Returns true if the turtle is currently hidden
fn write(&mut self, text: &str)
Write the text on the screen. The lower-left corner of the Text starts where the turtle is.
fn flood(&mut self)
Perform a floodfill at the current turtle position