1mod draw;
2mod save;
3
4use crate::{VrellisAlgorithm, VrellisPoint};
5use image::{GrayAlphaImage, GrayImage, RgbImage};
6use std::{
7 collections::HashSet,
8 fmt::{self, Debug, Formatter},
9};
10
11#[derive(Clone)]
12pub struct VrellisCanvas {
13 pub algorithm: VrellisAlgorithm,
14 pub min_distance: u32,
15 pub inverted_color: bool,
16 pub target_image: RgbImage,
17 pub current_image: GrayAlphaImage,
18 pub current_composite_image: GrayImage,
19 pub points: Vec<VrellisPoint>,
20 pub path: Vec<u32>,
21 pub path_banned: HashSet<(u32, u32)>,
22 pub last_point: VrellisPoint,
23 pub line_width: f32,
24}
25
26impl Debug for VrellisCanvas {
27 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
28 f.debug_struct("VrellisCanvas")
29 .field("width", &self.target_image.width())
30 .field("height", &self.target_image.height())
31 .field("path", &self.path)
32 .finish()
33 }
34}
35
36impl VrellisCanvas {
37 pub fn steps(&mut self, n: u32) {
38 for _ in 0..n {
39 if let None = self.next() {
40 break;
41 }
42 }
43 }
44}