diff --git a/assets/index.html b/assets/index.html
index 9e4d6ad..0fa9fcc 100644
--- a/assets/index.html
+++ b/assets/index.html
@@ -24,7 +24,7 @@
width: 100%;
max-width: 600px;
background: white;
- border-radius: 16px;
+ border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
padding: 35px;
margin: 40px 20px;
@@ -73,7 +73,10 @@
border-color: #764ba2;
outline: none;
}
-
+ input:invalid textarea:invalid {
+ border-color: #760000;
+ outline: none;
+ }
textarea {
resize: vertical;
min-height: 100px;
diff --git a/src/main.rs b/src/main.rs
index a6e2c1e..f6dfce5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -74,28 +74,39 @@ fn get_files(options: GenerateOptions) -> Vec<(String, Vec)> {
let mut files: Vec<(String, Vec)> = Vec::new();
use text_to_png::TextRenderer;
let renderer = TextRenderer::default();
+ let image_file_ending = "png";
for f in options.filenames {
let mut imgbuf = image::ImageBuffer::new(options.width, options.height);
for (x, y, pixel) in imgbuf.enumerate_pixels_mut() {
- *pixel = image::Rgba([255, 0, 2, 255]);
+ *pixel = image::Rgba([190, 190, 190, 255]);
}
let textpngdata = renderer
- .render_text_to_png_data(&f, 64, "Dark Turquoise")
+ .render_text_to_png_data(format!("{}.{}", &f, image_file_ending), 100, "White")
.unwrap();
- let other = image::ImageReader::new(Cursor::new(textpngdata.data))
+ let pngtextsource = image::ImageReader::new(Cursor::new(textpngdata.data))
.with_guessed_format()
.unwrap()
.decode()
.unwrap();
- imgbuf.copy_from(&other, 0, 0).unwrap();
+ let resized_text = pngtextsource.resize(
+ options.width / 2,
+ options.height,
+ image::imageops::FilterType::Nearest,
+ );
+ let xpos = (imgbuf.width() - resized_text.width()) / 2;
+ let ypos = (imgbuf.height() - resized_text.height()) / 2;
+ imgbuf.copy_from(&resized_text, xpos, ypos).unwrap();
let mut buf = Cursor::new(Vec::new());
imgbuf.write_to(&mut buf, image::ImageFormat::Png).unwrap();
- files.push((String::from(format!("{}.png", f)), buf.into_inner()));
+ files.push((
+ String::from(format!("{}.{}", f, image_file_ending)),
+ buf.into_inner(),
+ ));
}
files