Struct Canvas

Source
pub struct Canvas { /* private fields */ }

Implementations§

Source§

impl Canvas

Source

pub fn new() -> Canvas

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

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 17)
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

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 16)
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}

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>,

Source§

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>,

Source§

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.