pub struct Canvas { /* private fields */ }
Implementations§
source§impl Canvas
impl Canvas
sourcepub fn new() -> Canvas
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();
}
sourcepub fn save_eps<W: Write>(&self, wr: &mut W) -> Result<()>
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();
}
sourcepub fn save_svg<W: Write>(&self, wr: &mut W) -> Result<()>
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
impl Turtle for Canvas
source§fn forward<T: Into<Distance>>(&mut self, distance: T)
fn forward<T: Into<Distance>>(&mut self, distance: T)
Move turtle forward by specified distance
.
source§fn 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.source§fn 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.source§fn is_pen_down(&self) -> bool
fn is_pen_down(&self) -> bool
Returns
true
if pen is down.source§fn backward<T: Into<Distance>>(&mut self, distance: T)
fn backward<T: Into<Distance>>(&mut self, distance: T)
Move turtle backward by specified
distance
.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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more