From 89c2ac305967ba03ef9b704e621ff0ff886ca308 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 16 Dec 2019 12:56:40 +0100 Subject: also use a mask for major trait images While it doesn't look as ugly if you have a major trait with a thick black border, it still looks a bit off, especially since some of them do come with the proper alpha channel, while others don't. This fix uses the same mask for all major traits now as well, which should make them look more uniform and remove the thick black border. --- src/render.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/render.rs') diff --git a/src/render.rs b/src/render.rs index cbfd54f..7b796e1 100644 --- a/src/render.rs +++ b/src/render.rs @@ -119,18 +119,23 @@ pub struct Renderer<'r> { api: &'r mut Api, options: RenderOptions, minor_mask: DynamicImage, + major_mask: DynamicImage, } impl<'r> Renderer<'r> { /// Create a new renderer using the given API. pub fn new(api: &mut Api, options: RenderOptions) -> Renderer<'_> { let minor_mask = image::load_from_memory(include_bytes!("minor_trait_mask.png")) - .expect("Mask image could not be loaded") + .expect("Minor mask image could not be loaded") + .resize(options.trait_size, options.trait_size, CatmullRom); + let major_mask = image::load_from_memory(include_bytes!("major_trait_mask.png")) + .expect("Major mask image could not be loaded") .resize(options.trait_size, options.trait_size, CatmullRom); Renderer { api, options, minor_mask, + major_mask, } } @@ -190,6 +195,7 @@ impl<'r> Renderer<'r> { } else { major_img.to_rgba() }; + let major_img = with_mask(&major_img, &self.major_mask); let y_slice = buffer.height() / TRAITS_PER_TIER; let y_pos = vertical_pos as u32 * y_slice + half(y_slice - major_img.height()); let x_slice = (buffer.width() - self.options.traitline_x_offset) / TOTAL_COLUMN_COUNT; -- cgit v1.2.3