Trait 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 7)
4fn main() {
5    let mut t = Canvas::new();
6    t.forward(100.0);
7    t.right(90.0);
8    t.forward(100.0);
9    t.pen_up();
10    t.forward(10.0);
11    t.pen_down();
12    t.right(90.0);
13    t.forward(100.0);
14    t.right(90.0);
15    t.forward(100.0);
16    t.save_svg(&mut File::create("test.svg").unwrap()).unwrap();
17    t.save_eps(&mut File::create("test.eps").unwrap()).unwrap();
18}
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)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§