From 6c2e7963f2dfc2004857d7f1336fb6cf95c3b3b4 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sun, 8 Dec 2019 03:28:13 +0100 Subject: use imageproc to draw the rectangle Doesn't change the outcome but looks better to read --- src/render.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/render.rs b/src/render.rs index 53edd2c..1b15c1c 100644 --- a/src/render.rs +++ b/src/render.rs @@ -4,10 +4,9 @@ use image::{ imageops, CatmullRom, DynamicImage, GenericImage, GenericImageView, ImageBuffer, Pixel, Primitive, Rgba, RgbaImage, }; -use imageproc::drawing; +use imageproc::{drawing, rect::Rect}; use num_traits::NumCast; use rusttype::{Font, Scale, SharedBytes}; -use std::cmp::min; quick_error! { #[derive(Debug)] @@ -398,12 +397,8 @@ fn draw_thick_line( let mut line_buffer: RgbaImage = ImageBuffer::new(line_length, line_length); let halfway = (line_length - thickness) / 2; - for i in 0..thickness { - for x in 0..line_length { - let y = halfway + i; - line_buffer.put_pixel(x, y, color); - } - } + let rect = Rect::at(0, halfway as i32).of_size(line_length, thickness); + drawing::draw_filled_rect_mut(&mut line_buffer, rect, color); line_buffer = imageproc::geometric_transformations::rotate_about_center( &line_buffer, -- cgit v1.2.3