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§
sourcefn forward<T: Into<Distance>>(&mut self, distance: T)
fn forward<T: Into<Distance>>(&mut self, distance: T)
Move turtle forward by specified distance
.
sourcefn move_forward<T: Into<Distance>>(&mut self, distance: T)
fn move_forward<T: Into<Distance>>(&mut self, distance: T)
Move turtle forward by specified distance
without drawing.
sourcefn rotate<T: Into<Degree>>(&mut self, angle: T)
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.
sourcefn is_pen_down(&self) -> bool
fn is_pen_down(&self) -> bool
Returns true
if pen is down.
fn goto(&mut self, pos: Position)
Provided Methods§
sourcefn backward<T: Into<Distance>>(&mut self, distance: T)
fn backward<T: Into<Distance>>(&mut self, distance: T)
Move turtle backward by specified distance
.
sourcefn right<T: Into<Degree>>(&mut self, angle: T)
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();
}
fn home(&mut self)
Object Safety§
This trait is not object safe.