turtle-svg

Crates.ioturtle-svg
lib.rsturtle-svg
version0.1.1
sourcesrc
created_at2022-09-08 20:45:26.000429
updated_at2022-09-08 21:26:57.64914
descriptionTurtle graphics, SVG rendering
homepagehttps://github.com/theobori/turtle-svg
repositoryhttps://github.com/theobori/turtle-svg
max_upload_size
id661313
size18,030
Théo Bori (theobori)

documentation

README

turtle-svg

How to build and run ?

  1. Install the dependencies
    • cargo

Usage example

use turtle_svg::{
    turtle::TurtleSvg,
    color::ColorPre
};

fn main() {
    let mut turtle = TurtleSvg::new();
    
    // Pen settings
    turtle.set_pen_size(5.);
    turtle.set_pen_color(ColorPre::Red);
    turtle.set_background_color(ColorPre::None);

    // Square
    turtle.forward(40.);
    turtle.right(90.);
    turtle.forward(40.);
    turtle.right(90.);
    turtle.forward(40.);
    turtle.right(90.);
    turtle.forward(40.);

    // Drawing size, name
    turtle.drawing_mut().set_size((300., 100.));
    turtle.drawing_mut().set_center((20., 20.));
    turtle.drawing_mut().save_svg("red_square.svg");
}

Documentation

Run cargo doc --open to read the documentation in the browser.

Commit count: 8

cargo fmt