impl fmt::Debug for Turtle

main
serr 2025-06-26 17:26:31 +03:00
parent 5cc5ce2b2b
commit 722682e131
2 changed files with 13 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use turtle::{defaults, Turtle};
#[allow(dead_code)]
fn polygon(corners_number: u32, steps_count: u32, output_path: &'static str) {
let mut turtle = Turtle::new();
let default_pos = defaults::position();
let side_length = turtle.step_length() * steps_count;

View File

@ -3,6 +3,7 @@
use imageproc::{drawing};
use imageproc::image::{ImageBuffer, ImageResult, Rgb};
use std::path::Path;
use std::fmt;
type ImgBufU8 = ImageBuffer<Rgb<u8>, Vec<u8>>;
type Colour = Rgb<u8>;
@ -50,6 +51,17 @@ pub struct Turtle {
angle: f64,
}
impl fmt::Debug for Turtle {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Turtle")
.field("colour", &self.colour)
.field("pos", &self.pos)
.field("step_length", &self.step_length)
.field("angle", &self.angle)
.finish()
}
}
impl Turtle {
pub fn new() -> Self {
let mut buf = ImageBuffer::new(defaults::WIDTH, defaults::HEIGHT);