Struct turtle::Canvas

source ·
pub struct Canvas { /* private fields */ }

Implementations§

source§

impl Canvas

source

pub fn new() -> Canvas

Examples found in repository?
examples/ex1.rs (line 7)
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

pub fn save_eps<W: Write>(&self, wr: &mut W) -> Result<()>

Saves the turtle graphic as Embedded Postscript (EPS)

Examples found in repository?
examples/ex1.rs (line 19)
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

pub fn save_svg<W: Write>(&self, wr: &mut W) -> Result<()>

Saves the turtle graphic as Scalable Vector Graphic (SVG).

Examples found in repository?
examples/ex1.rs (line 18)
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();
}

Trait Implementations§

source§

impl Turtle for Canvas

source§

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

Move turtle forward by specified distance.

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, position: Position)

Positions the turtle exactly at position.

source§

fn push(&mut self)

Push current turtle state on stack.

source§

fn pop(&mut self)

Restore previously saved turtle state.

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 move_forward<T: Into<Distance>>(&mut self, distance: T)

Move turtle forward by specified distance without drawing.
source§

fn is_pen_down(&self) -> bool

Returns true if pen is down.
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.
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)

Auto Trait Implementations§

§

impl Freeze for Canvas

§

impl RefUnwindSafe for Canvas

§

impl Send for Canvas

§

impl Sync for Canvas

§

impl Unpin for Canvas

§

impl UnwindSafe for Canvas

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.