use crate::data::pointing::KusaPoint;
use crate::paint_tool::Nib;
use crate::piston_wrapper::kusa_image::KusaImage;
use crate::settings::Settings;
pub struct SquareNib {}
impl Nib for SquareNib {
fn put_pixel(&self, settings: &Settings, k_image: &mut KusaImage, center: &KusaPoint) {
let radius = settings.paint_thickness / 2.0;
let left = {
let mut left = (center.x - radius).round() as i16;
if left < 0 {
left = 0;
}
left
};
let right = {
let mut right = (center.x + radius).round() as i16;
if settings.image_width as i16 <= right {
right = settings.image_width as i16; }
right as i16
};
let top = {
let mut top = (center.y - radius).round() as i16;
if top < 0 {
top = 0;
}
top
};
let bottom = {
let mut bottom = (center.y + radius).round() as i16;
if settings.image_height as i16 <= bottom {
bottom = settings.image_width as i16; }
bottom as i16
};
for y in top..bottom {
for x in left..right {
k_image.set_pixel(x as u32, y as u32, &settings.paint_color);
}
}
}
}