|
2 | 2 |
|
3 | 3 | use factor::factor::factor;
|
4 | 4 |
|
| 5 | +use crate::color::palette::palette_from_abbr; |
| 6 | + |
5 | 7 | pub mod color;
|
6 | 8 | pub mod file_data;
|
7 | 9 | pub mod image;
|
@@ -34,6 +36,13 @@ pub enum ImageType {
|
34 | 36 | }
|
35 | 37 |
|
36 | 38 | impl ImageType {
|
| 39 | + pub fn default_color_palette(&self) -> ColorPalette { |
| 40 | + match self { |
| 41 | + Self::CGA => palette_from_abbr("cga0"), |
| 42 | + Self::EGA => palette_from_abbr("ega"), |
| 43 | + } |
| 44 | + } |
| 45 | + |
37 | 46 | pub fn palette_length(&self) -> usize {
|
38 | 47 | match self {
|
39 | 48 | Self::CGA => 4,
|
@@ -62,17 +71,19 @@ impl ImageType {
|
62 | 71 | }
|
63 | 72 |
|
64 | 73 | pub fn widths(&self, byte_count: usize) -> Vec<i64> {
|
65 |
| - Self::factors(self.pixel_count(byte_count), 80) |
| 74 | + let widths = Self::factors(self.pixel_count(byte_count), 8, 80); |
| 75 | + println!("{:?}", widths); |
| 76 | + widths |
66 | 77 | }
|
67 | 78 |
|
68 | 79 | pub fn heights(&self, byte_count: usize, width: usize) -> Vec<i64> {
|
69 |
| - Self::factors(self.pixel_count(byte_count) / width, 50) |
| 80 | + Self::factors(self.pixel_count(byte_count) / width, 4, 50) |
70 | 81 | }
|
71 | 82 |
|
72 |
| - pub fn factors(num: usize, upper: usize) -> Vec<i64> { |
| 83 | + pub fn factors(num: usize, lower: usize, upper: usize) -> Vec<i64> { |
73 | 84 | factor(num.try_into().unwrap())
|
74 | 85 | .into_iter()
|
75 |
| - .filter(|&x| x > 4 && x <= upper.try_into().unwrap()) |
| 86 | + .filter(|&x| x >= lower.try_into().unwrap() && x <= upper.try_into().unwrap()) |
76 | 87 | .collect()
|
77 | 88 | }
|
78 | 89 | }
|
0 commit comments