aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2019-12-14 01:45:23 +0100
committerDaniel Schadt <kingdread@gmx.de>2019-12-14 01:46:24 +0100
commit2aef95f62788163b789fae92b5a6546b2413d9e4 (patch)
treec84f3e41459a12fb8b2c44d56245d5caa3c1b1a5
parenta1722af9a32d10826c142664050d30307defcb89 (diff)
downloadkondou-2aef95f62788163b789fae92b5a6546b2413d9e4.tar.gz
kondou-2aef95f62788163b789fae92b5a6546b2413d9e4.tar.bz2
kondou-2aef95f62788163b789fae92b5a6546b2413d9e4.zip
correctly render transparent backgrounds
Previously, some areas were "double exposed" to the transparency, making them a bit darker than the rest. The solution is to make sure that each part is drawn with the correct background color, and then only copying pixels instead of blending them to the final canvas.
-rw-r--r--src/render.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/render.rs b/src/render.rs
index e3f2d31..cbfd54f 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -135,9 +135,10 @@ impl<'r> Renderer<'r> {
}
pub fn render_skills(&mut self, skills: &[Option<Skill>]) -> Result<RgbaImage, RenderError> {
- let mut buffer = ImageBuffer::new(
+ let mut buffer = ImageBuffer::from_pixel(
skills.len() as u32 * self.options.skill_size,
self.options.skill_size,
+ self.options.background_color,
);
for (i, skill) in skills.iter().enumerate() {
if let Some(skill) = skill {
@@ -294,7 +295,11 @@ impl<'r> Renderer<'r> {
specialization: &Specialization,
) -> Result<RgbaImage, RenderError> {
let scale = self.options.text_size;
- let mut buffer = ImageBuffer::new(self.options.traitline_width, scale);
+ let mut buffer = ImageBuffer::from_pixel(
+ self.options.traitline_width,
+ scale,
+ self.options.background_color,
+ );
drawing::draw_text_mut(
&mut buffer,
self.options.text_color,
@@ -367,7 +372,7 @@ impl<'r> Renderer<'r> {
Alignment::Center => half(width - image.width()),
Alignment::Right => width - image.width(),
};
- imageops::overlay(&mut buffer, image, pos_x, pos_y);
+ buffer.copy_from(image, pos_x, pos_y);
pos_y += image.height();
}