Trait turtle::Turtle

source ·
pub trait Turtle {
Show 14 methods // Required methods fn forward<T: Into<Distance>>(&mut self, distance: T); fn move_forward<T: Into<Distance>>(&mut self, distance: T); fn rotate<T: Into<Degree>>(&mut self, angle: T); fn is_pen_down(&self) -> bool; fn pen_down(&mut self); fn pen_up(&mut self); fn goto(&mut self, pos: Position); fn push(&mut self); fn pop(&mut self); // Provided methods fn backward<T: Into<Distance>>(&mut self, distance: T) { ... } fn right<T: Into<Degree>>(&mut self, angle: T) { ... } fn left<T: Into<Degree>>(&mut self, angle: T) { ... } fn is_pen_up(&self) -> bool { ... } fn home(&mut self) { ... }
}

Required Methods§

source

fn forward<T: Into<Distance>>(&mut self, distance: T)

Move turtle forward by specified distance.

source

fn move_forward<T: Into<Distance>>(&mut self, distance: T)

Move turtle forward by specified distance without drawing.

source

fn rotate<T: Into<Degree>>(&mut self, angle: T)

Rotate around angle. If angle is positive, the turtle is turned to the left, if negative, to the right.

source

fn is_pen_down(&self) -> bool

Returns true if pen is down.

source

fn pen_down(&mut self)

Put the pen down.

source

fn pen_up(&mut self)

Put the pen up.

source

fn goto(&mut self, pos: Position)

source

fn push(&mut self)

Push current turtle state on stack.

source

fn pop(&mut self)

Restore previously saved turtle state.

Provided Methods§

source

fn backward<T: Into<Distance>>(&mut self, distance: T)

Move turtle backward by specified distance.

source

fn right<T: Into<Degree>>(&mut self, angle: T)

Turn turtle right by angle degree.

Examples found in repository?
examples/ex1.rs (line 9)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn main() {
    let mut t = Canvas::new();
    t.forward(100.0);
    t.right(90.0);
    t.forward(100.0);
    t.pen_up();
    t.forward(10.0);
    t.pen_down();
    t.right(90.0);
    t.forward(100.0);
    t.right(90.0);
    t.forward(100.0);
    t.save_svg(&mut File::create("test.svg").unwrap()).unwrap();
    t.save_eps(&mut File::create("test.eps").unwrap()).unwrap();
}
source

fn left<T: Into<Degree>>(&mut self, angle: T)

Turn turtle left by angle degree.

source

fn is_pen_up(&self) -> bool

Returns true if pen is up.

source

fn home(&mut self)

Object Safety§

This trait is not object safe.

Implementors§