diff --git a/src/main.rs b/src/main.rs index 7fdeb59..6c53778 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,12 +3,7 @@ mod turtle; use turtle::Turtle; fn main() { - let mut turtle = Turtle::new(); - println!("Pos = {:?}", turtle.position()); - - let start = (50, 50); - let end = (200, 200); - turtle.draw_line(start, end); + turtle.draw_line((50, 50), (200, 200)); turtle.save("output.png").unwrap(); } diff --git a/src/turtle.rs b/src/turtle.rs index d6feae6..a03ffdd 100644 --- a/src/turtle.rs +++ b/src/turtle.rs @@ -10,11 +10,12 @@ type Coord = (i32, i32); const DEFAULT_WIDTH: u32 = 800; const DEFAULT_HEIGHT: u32 = 800; +const DEFAULT_BACKGROUND_COLOUR: Colour = Rgb([255u8, 255u8, 255u8]); +const DEFAULT_COLOUR: Colour = Rgb([0u8, 0u8, 0u8]); pub struct Turtle { buf: ImgBufU8, colour: Colour, - background_colour: Colour, pos: Coord, angle: f64, } @@ -23,13 +24,12 @@ impl Turtle { pub fn new() -> Self { let mut buf = ImageBuffer::new(DEFAULT_WIDTH, DEFAULT_HEIGHT); for pixel in buf.pixels_mut() { - *pixel = Rgb([255u8, 255u8, 255u8]); + *pixel = DEFAULT_BACKGROUND_COLOUR; } Turtle { buf, - colour: Rgb([0u8, 0u8, 0u8]), - background_colour: Rgb([255u8, 255u8, 255u8]), + colour: DEFAULT_COLOUR, pos: (0, 0), angle: 0.0, }