You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: utils.rs
    path of file: ./repos/silicon/src
    
    the code of the file until where you have to start completion: use crate::error::ParseColorError;
use image::imageops::{crop_imm, resize, FilterType};
use image::Pixel;
use image::{GenericImage, GenericImageView, Rgba, RgbaImage};
use imageproc::drawing::{draw_filled_rect_mut, draw_line_segment_mut};
use imageproc::rect::Rect;

pub trait ToRgba {
    type Target;
    fn to_rgba(&self) -> Self::Target;
}

/// Parse hex color (#RRGGBB or #RRGGBBAA)
impl ToRgba for str {
    type Target = Result<Rgba<u8>, ParseColorError>;

    fn to_rgba(&self) -> Self::Target {
        if self.as_bytes()[0] != b'#' {
            return Err(ParseColorError::InvalidDigit);
        }
        let mut color = u32::from_str_radix(&self[1..], 16)?;

        match self.len() {
            // RGB or RGBA
            4 | 5 => {
                let a = if self.len() == 5 {
               
    
pub(crate) fn add_window_controls(image: &mut RgbaImage, params: &WindowControlsParams) {
    let color = [
        ("#FF5F56", "#E0443E"),
        ("#FFBD2E", "#DEA123"),
        ("#27C93F", "#1AAB29"),
    ];

    let background = image.get_pixel_mut(37, 37);
    background.0[3] = 0;

    let mut title_bar = RgbaImage::from_pixel(params.width * 3, params.height * 3, *background);
    let step = (params.radius * 2) as i32;
    let spacer = step * 2;
    let center_y = (params.height / 2) as i32;

    for (i, (fill, outline)) in color.iter().enumerate() {
        draw_filled_circle_mut(
            &mut title_bar,
            ((i as i32 * spacer + step) * 3, center_y * 3),
            (params.radius + 1) as i32 * 3,
            outline.to_rgba().unwrap(),
        );
        draw_filled_circle_mut(
            &mut title_bar,
            ((i as i32 * spacer + step) * 3, center_y * 3),
            params.radius as i32 * 3,
            fill.to_rgba().unwrap(),
        );
    }
    // create a big image and resize it to blur the edge
    // it looks better than `blur()`
    let title_bar = resize(
        &title_bar,
        params.width,
        params.height,
        FilterType::Triangle,
    );

    copy_alpha(&title_bar, image, params.padding, params.padding);
}