Struct drawille::Turtle
[−]
[src]
pub struct Turtle { pub x: f32, pub y: f32, pub brush: bool, pub rotation: f32, pub cvs: Canvas, }
A ‘turtle’ that can walk around a canvas drawing lines.
Fields
x: f32
y: f32
brush: bool
rotation: f32
cvs: Canvas
Methods
impl Turtle
[src]
fn new(x: f32, y: f32) -> Turtle
Create a new Turtle
, starting at the given coordinates.
The turtle starts with its brush down, facing right.
fn from_canvas(x: f32, y: f32, cvs: Canvas) -> Turtle
Creates a new Turtle
with the provided Canvas
, starting at the given coordinates.
The turtle starts with its brush down, facing right.
fn width(self, width: u32) -> Turtle
Sets the width of a Turtle
’s Canvas
, and return it for use again.
fn height(self, height: u32) -> Turtle
Sets the height of a Turtle
’s Canvas
, and return it for use again.
fn up(&mut self)
Lifts the Turtle
’s brush.
fn down(&mut self)
Puts down the Turtle
’s brush.
fn toggle(&mut self)
Toggles the Turtle
’s brush.
fn forward(&mut self, dist: f32)
Moves the Turtle
forward by dist
steps.
fn back(&mut self, dist: f32)
Moves the Turtle
backward by dist
steps.
fn teleport(&mut self, x: f32, y: f32)
Teleports the Turtle
to the given coordinates.
Note that this draws a line between the old position and the new one if the Turtle
’s
brush is down.
fn right(&mut self, angle: f32)
Turns the Turtle
right (clockwise) by angle
degrees.
fn left(&mut self, angle: f32)
Turns the Turtle
left (clockwise) by angle
degrees.
fn frame(&self) -> String
Writes the Turtle
’s Canvas
to a String
and returns it.