diff --git a/src/lib.rs b/src/lib.rs index 646edbc..eb790f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,7 +72,7 @@ impl ImageType { pub fn factors(num: usize, upper: usize) -> Vec { factor(num.try_into().unwrap()) .into_iter() - .filter(|&x| x >= 4 && x <= upper.try_into().unwrap()) + .filter(|&x| x > 4 && x <= upper.try_into().unwrap()) .collect() } } diff --git a/src/wasm/image.rs b/src/wasm/image.rs index 654eb1d..50b7698 100644 --- a/src/wasm/image.rs +++ b/src/wasm/image.rs @@ -17,12 +17,10 @@ pub struct Props { pub struct ImageComponent { width: usize, - height: usize, } pub enum Msg { Width(Event), - Height(Event), } impl ImageComponent { @@ -36,7 +34,7 @@ impl ImageComponent { let palette = palette_from_abbr("cga0"); let mut bytes: Vec = Vec::new(); - let _ = png::write_to(&mut bytes, tile(image.data(), self.height), palette.clone()); + let _ = png::write_to(&mut bytes, image.data(), palette.clone()); bytes }; format!("data:application/png;base64,{}", STANDARD.encode(data)) @@ -54,13 +52,13 @@ impl ImageComponent { let palette = palette_from_abbr("cga0"); let mut bytes: Vec = Vec::new(); - let _ = png::write_to(&mut bytes, tile(p.data(), self.height), palette.clone()); + let _ = png::write_to(&mut bytes, p.data(), palette.clone()); let src = format!("data:application/png;base64,{}", STANDARD.encode(bytes)); html! { - - {p.width()} +
+

{p.width()}

- +
} }) .collect() @@ -75,7 +73,6 @@ impl Component for ImageComponent { fn create(_ctx: &Context) -> Self { Self { width: 320, - height: 200, } } @@ -85,10 +82,6 @@ impl Component for ImageComponent { let input: HtmlInputElement = e.target_unchecked_into(); self.width = input.value().parse().expect("fail to parse width"); } - Msg::Height(e) => { - let input: HtmlInputElement = e.target_unchecked_into(); - self.height = input.value().parse().expect("fail to parse width"); - } } true } @@ -101,19 +94,19 @@ impl Component for ImageComponent { html! { <> -
+

{ file.name.to_string() }

- + - -
- {self.previews(file)} +
+ {self.previews(file)} +
} } diff --git a/src/wasm/main.rs b/src/wasm/main.rs index de656de..3b42fdb 100644 --- a/src/wasm/main.rs +++ b/src/wasm/main.rs @@ -40,7 +40,7 @@ impl Component for App { html! {

{ "Process your CGA/EGAs" }

- +
{{ images }}
} diff --git a/src/wasm/styles.css b/src/wasm/styles.css index 599f0a1..7b836f6 100644 --- a/src/wasm/styles.css +++ b/src/wasm/styles.css @@ -60,6 +60,19 @@ label { background: #313737; border-radius: 1rem; } +.preview-row { + display: flex; + flex-direction: row; + padding: 2rem; + margin: 1rem; + background: #313737; + border-radius: 1rem; +} +.preview-row .preview-tile { + background: #111717; + border-radius: 1rem; +} + .preview-media { flex: 1; diff --git a/test.cga b/test.cga index 1b1c291..bb7b208 100644 Binary files a/test.cga and b/test.cga differ