Skip to content

Commit 13d3746

Browse files
committed
refactored data_export initialiser
1 parent 3cdf49e commit 13d3746

File tree

3 files changed

+41
-45
lines changed

3 files changed

+41
-45
lines changed

palette_default.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
palette = [
2+
87,109,71,205,219,204,25,115,31,15,30,17,96,127,110,233,235,216,242,223,90,33,44,33,22,136,174,209,218,219,121,85,55,34,42,9,156,254,18,222,235,204,92,96,88,21,42,38,82,242,219,215,241,231,114,163,99,34,25,35,158,42,186,230,218,215,157,172,5,31,34,16,91,105,129,206,219,238,33,121,248,14,28,50,83,107,159,225,223,213,191,151,17,41,35,27,142,134,199,216,213,239,59,40,187,19,35,40,99,246,140,205,228,222,11,54,112,17,13,41,131,52,218,221,201,221,107,27,20,29,32,20,126,236,145,207,249,215,6,231,51,15,42,29,116,111,181,235,206,232,240,8,148,59,23,47,232,180,233,242,234,241,175,162,166,51,28,26,240,65,46,236,210,218,119,90,169,23,30,26,66,152,39,230,226,217,246,129,170,54,47,29,193,250,68,222,250,219,54,222,159,26,47,40,154,158,167,226,228,222,127,142,83,19,39,31,26,174,168,203,234,239,73,173,218,31,42,33,182,168,52,232,237,222,151,203,197,19,55,41,4,244,137,201,232,218,80,89,82,29,37,40,156,207,245,225,234,231,118,135,74,16,44,29,10,220,163,201,230,221,72,90,78,21,42,29,100,251,157,226,250,233,182,223,184,27,34,40,35,49,137,216,220,220,170,186,100,29,48,38,66,198,210,201,234,217,19,146,1,30,48,6,223,239,50,243,253,219,193,255,176,49,50,49,206,146,221,229,210,222,100,9,27,39,2,27,213,7,194,227,203,225,80,89,83,28,40,28,149,233,147,237,241,211,217,165,18,27,20,34,0,0,255,203,192,229,100,12,47,41,4,22,229,20,130,234,203,220,119,75,106,14,41,45,0,255,255,205,227,251,117,31,224,41,35,39,212,254,95,243,228,226,208,45,186,28,11,49,21,46,211,218,205,249,195,68,253,42,17,53,146,73,175,210,227,229,6,218,133,31,41,18,249,111,11,252,206,210,239,10,143,59,23,40,239,177,181,221,230,225,1,136,91,19,47,13,151,247,13,237,230,219,216,66,209,32,28,45,47,161,155,227,231,216,239,160,48,45,44,32,128,195,214,230,237,223,184,174,42,24,24,33,13,19,226,224,211,251,252,139,252,39,45,36,63,225,39,214,249,209,126,240,103,17,51,14,12,172,14,203,236,211,82,187,147,34,29,28,196,52,79,229,219,208,109,177,61,14,25,25,5,24,141,202,225,233,83,251,198,12,44,31,16,101,56,223,205,229,245,15,253,60,22,60,237,162,233,223,242,243,21,250,185,6,36,45,33,44,180,221,206,232,209,76,153,54,12,24,230,22,46,223,196,213,30,22,134,7,26,17,32,192,9,207,237,219,97,180,214,29,49,46,137,218,156,220,231,213,97,101,19,37,32,25,200,155,186,225,236,240,72,207,211,23,35,44,113,75,144,220,201,215,119,9,48,18,15,24,25,115,150,203,230,233,73,200,185,10,35,45,10,85,175,196,224,243,33,180,244,11,37,31,61,116,6,210,209,216,94,27,195,31,14,35,155,85,85,242,217,212,254,121,88,55,39,29,186,194,147,217,232,223,26,133,113,21,22,21,146,50,61,226,224,201,136,212,20,44,32,25,217,45,181,226,201,214,64,40,8,9,28,15,14,185,112,203,245,228,84,252,185,21,38,51,86,54,227,222,229,229,163,253,77,42,38,23,178,57,114,230,211,207,138,104,15,26,21,28,72,66,215,208,215,234,63,127,129,28,27,37,167,95,171,232,223,234,162,159,176,30,23,26,81,28,32,220,213,215,152,149,159,49,29,22,242,83,18,233,210,222,96,68,229,13,30,58,10,177,237,202,237,247,83,191,212,41,26,30,248,18,32,224,205,219,17,96,192,23,12,27,168,6,24,214,208,202,18,132,63,12,18,38,78,14,244,201,223,237,6,241,122,31,45,29,243,124,113,240,210,234,148,26,233,43,3,53,198,3,194,226,214,217,81,179,14,23,31,11,105,72,76,205,211,201,12,87,6,24,14,16,182,27,128,237,200,209,190,46,21,45,11,12,173,44,76,236,223,214,192,215,110,41,35,40,137,69,211,210,199,246,20,0,228,9,15,42,53,122,113,226,220,216,229,110,86,46,40,17,139,210,55,226,230,226,141,107,227,24,22,40,51,75,96,220,226,213,186,207,82,53,35,24,241,80,110,239,205,211,146,33,48,42,35,36,195,250,241,244,238,239,227,125,143,33,37,23,39,171,42,219,222,211,187,78,116,34,38,46,85,231,254,202,250,232,7,242,76,12,46,41,93,129,253,203,236,223,5,230,3,12,41,13,93,105,105,224,206,223,172,14,153,31,26,35,83,196,127,212,221,214,85,48,58,17,8,21,57,20,110,208,218,215,81,194,83,22,43,34,100,150,193,209,228,218,45,147,21,17,23,8,98,44,43,229,228,208,204,252,95,51,43,42,209,96,242,238,223,223,172,159,15,48,32,15,215,104,108,246,230,209,230,213,37,38,33,14,78,52,79,226,209,208,203,94,62,50,41,31,197,235,187,222,251,224,52,248,79,32,43,19,210,100,79,244,231,222,214,220,174,42,43,42,122,127,167,213,217,236,56,85,195,26,23,26,154,99,15,215,234,224,40,244,253,22,32,42,139,19,84,231,194,229,184,6,221,38,28,59,126,218,251,212,230,229,42,92,55,13,26,15,67,118,67,211,222,229,92,129,241,26,17,53,120,14,189,223,223,245,141,243,243,27,41,42,79,85,98,218,233,203,142,255,0,31,46,13,113,113,106,230,214,226,198,73,173,45,23,32,168,114,86,230,210,225,142,43,185,27,22,52,78,133,234,226,221,233,202,111,102,49,18,13,191,38,8,241,197,214,211,14,178,33,32,43,58,248,168,199,222,227,10,0,122,31,3,28,239,25,109,242,201,233,169,58,231,27,38,44,53,253,123,220,236,230,177,111,192,26,21,43,31,63,153,196,205,224,8,53,114,28,35,40,221,232,211,222,238,246,29,146,231,26,20,29,181,21,6,236,198,209,177,40,140,37,6,22,123,13,38,225,206,197,154,111,15,43,17,6,195,29,33,233,219,219,143,200,195,27,52,44,80,218,157,213,227,231,101,70,166,26,27,23,108,151,21,214,226,209,76,131,125,13,22,46,33,49,250,223,225,239,224,222,133,46,43,44,150,128,219,216,237,240,49,238,172,6,31,47,0,10,204,193,195,226,17,20,75,28,28,25,214,208,129,226,231,233,66,110,211,19,22,53,92,73,214,214,220,249,96,160,248,31,49,54,152,238,186,229,225,221,153,37,56,28,32,30,75,220,188,218,223,240,145,41,205,35,20,46,141,119,167,209,210,225,2,31,106,3,7,43,22,25,239,225,211,233,255,139,98,43,23,40,90,48,227,229,220,250,216,188,246,27,34,58,5,86,218,195,214,219,26,103,7,18,21,27,125,71,212,210,212,230,31,96,101,17,37,22,108,200,76,209,245,212,34,236,95,20,55,17,130,209,47,235,228,212,225,89,120,58,31,20,245,160,40,226,239,203,36,228,59,17,44,32,102,128,204,229,209,237,204,16,166,31,14,30,47,99,75,203,203,223,53,1,180,16,20,44,75,164,172,202,226,239,12,115,214,12,31,50,87,138,190,231,221,232,238,104,139,41,25,26,93,100,71,215,224,211,102,162,89,25,31,14,101,90,28,208,218,219,39,126,196,5,23,27,4,61,27,210,225,199,149,215,42,29,27,13,90,4,69,233,221,215,247,241,128,40,53,30,74,186,113,229,233,218,233,155,104,54,51,21,200,255,67,245,224,203,235,10,27,47,15,17,142,116,113,212,210,207,29,38,19,23,25,17,162,165,124,228,218,223,133,49,134,29,15,29,105,77,104,219,203,205,119,22,6,23,4,3,68,12,25,230,216,223,247,193,229,58,53,39,224,232,87,224,230,208,38,83,52,29,15,29,197,38,181,219,197,227,32,13,108,29,15,37,203,107,192,243,212,220,215,65,38,42,11,13,123,28,73,231,217,215,198,178,118,41,37,36,133,120,172,226,211,235,152,39,180,44,33,33,207,231,87,219,223,230,21,30,230,29,16,28,213,104,0,248,232,191,241,223,3,38,33,11,67,47,85,210,209,226,88,96,194,14,37,24,27,201,1,202,240,215,64,191,190,32,36,35,192,103,91,245,210,204,245,50,12,54,9,6,189,26,36,225,219,214,85,198,152,15,29,21,36,40,16,217,204,221,174,68,227,48,33,31,211,197,26,227,217,194,78,10,1,11,27,26,11,206,209,195,242,244,22,202,219,5,36,30,18,93,27,215,214,199,179,96,39,50,22,9,221,80,35,229,210,214,81,71,152,40,11,33,246,24,114,248,203,211,213,77,47,29,22,17,23,100,91,196,223,224,15,155,177,8,37,31,51,143,72,210,214,222,99,45,180,40,32,39,222,211,139,244,226,233,202,74,195,36,31,47,92,179,181,212,233,229,77,161,128,33,23,37,192,25,175,223,196,239,62,14,211,34,4,26,212,18,4,245,201,208,220,61,137,53,15,20,204,64,23,221,219,223,41,160,233,35,29,37,245,76,69,224,215,205,18,114,46,28,46,8,213,254,23,226,247,223,68,194,233,24,50,32,127,207,24,215,240,216,63,184,178,8,24,51,2,12,237,207,210,243,128,144,179,24,45,45,66,218,183,228,218,245,228,0,248,47,25,61,154,200,242,227,217,237,133,7,126,18,22,24,15,176,69,218,224,215,203,88,128,27,12,16,13,13,4,205,219,205,103,214,113,40,30,24,219,27,86,231,222,222,102,224,161,21,38,26,69,82,50,221,214,213,170,100,131,27,16,40,52,35,190,210,225,216,104,236,8,18,29,22,45,1,169,212,195,230,121,33,148,44,6,38,233,15,157,240,208,224,162,121,112,36,18,41,130,25,222,211,196,244,33,16,203,34,21,46,244,156,170,225,237,232,31,213,163,31,27,51,217,6,252,244,210,228,211,148,49,47,34,30,171,124,191,228,223,237,130,137,176,46,41,40,241,192,144,240,230,227,154,122,142,24,17,38,38,17,165,215,210,225,158,138,109,27,21,27,58,34,114,217,204,221,154,71,131,49,22,20,243,107,32,232,224,201,86,160,48,31,37,36,165,140,246,229,233,251,138,195,232,48,40,36,248,126,62,245,209,224,183,22,201,44,26,35,173,187,83,227,239,214,115,198,104,35,45,40,167,167,219,222,232,242,83,162,194,31,49,34,165,231,83,233,228,212,170,65,89,34,20,26,104,97,120,232,222,233,223,150,218,36,22,34,67,29,60,201,212,226,11,142,224,9,26,35,67,67,61,201,208,222,15,72,190,15,36,55,109,223,253,219,250,231,119,252,69,40,39,18,204,61,75,238,222,201,177,190,9,30,54,20,66,249,156,217,241,229,143,149,147,28,21,27,84,19,70,202,213,215,8,157,126,14,40,43,108,165,222,226,218,233,177,50,116,31,9,18,76,25,34,214,204,211,107,83,131,33,38,23,164,226,56,218,243,207,50,193,75,37,30,15,252,47,45,226,213,225,29,131,225,20,18,58,133,17,246,235,220,240,221,213,145,40,58,29,101,255,93,217,245,226,109,177,186,32,48,44,149,209,169,231,231,226,172,110,116,35,28,41,115,118,219,207,211,243,17,46,202,20,9,51,144,27,213,234,195,239,198,9,173,37,17,47,102,128,207,228,215,245,192,68,226,54,28,55,247,160,218,245,240,238,184,235,161,39,30,33,130,7,109,209,212,224,13,165,160,28,32,24,216,98,35,249,224,218,246,169,186,61,26,31,245,45,63,239,199,213,139,17,115,45,20,32,223,144,141,237,240,209,147,251,7,19,56,23,8,199,180,195,224,239,29,70,206,23,29,29,157,167,26,218,236,196,63,194,18,25,27,31,137,29,233,228,200,241,157,44,171,22,30,48,23,197,214,210,226,218,130,86,1,31,38,22,119,224,182,228,227,222,176,64,67,40,18,9,146,80,8,216,203,222,55,20,240,36,16,61,239,108,251,250,212,224,232,65,11,48,33,21,156,199,157,220,221,228,74,39,141,20,12,23,86,63,44,205,202,226,27,25,241,15,32,56,94,231,208,225,238,247,181,150,244,47,41,33,199,184,27,216,215,221,2,13,216,4,1,30,32,2,30,218,209,220,184,142,204,46,20,26,190,19,4,217,198,201,20,40,80,6,24,23,28,154,104,205,240,224,87,241,162,11,50,48,6,164,222,212,240,238,164,228,153,37,37,32,136,68,105,211,203,220,25,30,132,31,14,44,223,82,223,226,204,246,57,26,218,34,26,38,221,188,91,250,214,230,254,1,225,46,11,38,116,87,80,211,207,221,45,44,158,19,13,48,108,67,228,228,211,239,192,94,160,39,18,38,123,53,146,223,211,227,136,112,142,21,22,26,35,64,70,205,210,215,78,90,126,15,42,29,45,251,113,200,250,220,30,222,117,23,30,39,156,22,199,227,203,237,134,74,172,29,32,42,104,185,167,233,246,226,231,253,112,41,40,25,102,67,93,210,223,223,49,191,168,10,32,43,34,65,179,215,200,228,157,10,116,38,24,34,151,186,157,218,240,222,67,208,91,10,29,38,16,31,220,212,208,219,156,106,5,37,29,29,146,129,229,219,228,234,83,170,116,29,48,30,151,218,127,240,228,213,245,81,52,33,27,31,20,141,200,204,219,216,87,85,3,41,24,20,242,107,160,247,227,238,211,179,217,42,49,50,132,220,185,228,243,225,165,201,89,41,56,33,165,253,176,214,236,215,18,107,18,17,39,33,123,212,251,211,223,226,38,48,30,8,34,23,33,230,155,199,241,242,29,169,251,21,48,56,146,218,200,237,234,238,220,125,179,38,29,31,
3+
]
4+
iteration_division = 60.0

src/bin/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,27 @@ fn main() {
2222
.about("Sets the options file to use.")
2323
.takes_value(true)
2424
.required(false)
25+
)
26+
.arg(
27+
Arg::new("palette")
28+
.short('p')
29+
.long("palette")
30+
.value_name("FILE")
31+
.about("Sets the palette file to use.")
32+
.takes_value(true)
33+
.required(false)
2534
).get_matches();
2635

27-
2836
let mut settings = Config::default();
2937

3038
if let Some(p) = matches.value_of("options") {
3139
settings.merge(File::with_name(p).required(true)).unwrap();
3240
};
3341

42+
if let Some(p) = matches.value_of("palette") {
43+
settings.merge(File::with_name(p).required(true)).unwrap();
44+
};
45+
3446
if let Some(l) = matches.value_of("INPUT") {
3547
settings.merge(File::with_name(l).required(true)).unwrap();
3648
};

src/util/data_export.rs

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,60 +30,40 @@ pub struct DataExport {
3030

3131
impl DataExport {
3232
pub fn new(image_width: usize, image_height: usize, display_glitches: bool, data_type: DataType) -> Self {
33+
let mut rgb = Vec::new();
34+
let mut palette = Vec::new();
35+
let mut smooth_f16 = Vec::new();
36+
let mut smooth_f32 = Vec::new();
37+
3338
match data_type {
3439
DataType::COLOUR => {
35-
DataExport {
36-
image_width,
37-
image_height,
38-
rgb: vec![0u8; image_width * image_height * 3],
39-
palette: DataExport::generate_default_palette(),
40-
iterations: vec![0u32; image_width * image_height],
41-
smooth_f16: Vec::new(),
42-
smooth_f32: Vec::new(),
43-
display_glitches,
44-
data_type
45-
}
40+
rgb = vec![0u8; image_width * image_height * 3];
41+
palette = DataExport::generate_default_palette();
4642
},
4743
DataType::RAW => {
48-
DataExport {
49-
image_width,
50-
image_height,
51-
rgb: Vec::new(),
52-
palette: Vec::new(),
53-
iterations: vec![0u32; image_width * image_height],
54-
smooth_f16: vec![f16::ZERO; image_width * image_height],
55-
smooth_f32: Vec::new(),
56-
display_glitches,
57-
data_type
58-
}
44+
smooth_f16 = vec![f16::ZERO; image_width * image_height];
5945
},
6046
DataType::KFB => {
61-
DataExport {
62-
image_width,
63-
image_height,
64-
rgb: Vec::new(),
65-
palette: Vec::new(),
66-
iterations: vec![0u32; image_width * image_height],
67-
smooth_f16: Vec::new(),
68-
smooth_f32: vec![0.0f32; image_width * image_height],
69-
display_glitches,
70-
data_type
71-
}
47+
smooth_f32 = vec![0.0f32; image_width * image_height];
7248
},
7349
DataType::BOTH => {
74-
DataExport {
75-
image_width,
76-
image_height,
77-
rgb: vec![0u8; image_width * image_height * 3],
78-
palette: DataExport::generate_default_palette(),
79-
iterations: vec![0u32; image_width * image_height],
80-
smooth_f16: vec![f16::ZERO; image_width * image_height],
81-
smooth_f32: Vec::new(),
82-
display_glitches,
83-
data_type
84-
}
50+
rgb = vec![0u8; image_width * image_height * 3];
51+
palette = DataExport::generate_default_palette();
52+
smooth_f16 = vec![f16::ZERO; image_width * image_height];
8553
}
8654
}
55+
56+
DataExport {
57+
image_width,
58+
image_height,
59+
rgb,
60+
palette,
61+
iterations: vec![0u32; image_width * image_height],
62+
smooth_f16,
63+
smooth_f32,
64+
display_glitches,
65+
data_type
66+
}
8767
}
8868

8969
pub fn export_pixels(&mut self, pixel_data: &[PixelData], maximum_iteration: usize, reference: &Reference) {

0 commit comments

Comments
 (0)