pub fn draw_text_mut<'a, C>(
    canvas: &'a mut C,
    color: C::Pixel,
    x: i32,
    y: i32,
    scale: Scale,
    font: &'a Font<'a>,
    text: &'a str,
) where
    C: Canvas,
    <C::Pixel as Pixel>::Subpixel: ValueInto<f32> + Clamp<f32>,
{
    let image_width = canvas.width() as i32;
    let image_height = canvas.height() as i32;

    layout_glyphs(scale, font, text, |g, bb| {
        g.draw(|gx, gy, gv| {
            let gx = gx as i32 + bb.min.x;
            let gy = gy as i32 + bb.min.y;

            let image_x = gx + x;
            let image_y = gy + y;

            if (0..image_width).contains(&image_x) && (0..image_height).contains(&image_y) {
                let pixel = canvas.get_pixel(image_x as u32, image_y as u32);
                let weighted_color = weighted_sum(pixel, color, 1.0 - gv, gv);
                canvas.draw_pixel(image_x as u32, image_y as u32, weighted_color);
            }
        })
    });
}
/// Draws colored text on an image in place. `scale` is augmented font scaling on both the x and y axis (in pixels). Note that this function *does not* support newlines, you must do this manually.
Draws colored text on an image in place. `scale` is augmented font scaling on both the x and y axis (in pixels). Note that this function *does not* support newlines, you must do this manually.
Draws colored text on an image in place . ` scale ` is augmented font scaling on both the x and y axis ( in pixels ) . Note that this function * does not * support newlines you must do this manually .
pub fn draw_text_mut<'a, C>(
    canvas: &'a mut C,
    color: C::Pixel,
    x: i32,
    y: i32,
    scale: Scale,
    font: &'a Font<'a>,
    text: &'a str,
) where
    C: Canvas,
    <C::Pixel as Pixel>::Subpixel: ValueInto<f32> + Clamp<f32>,
{
    let image_width = canvas.width() as i32;
    let image_height = canvas.height() as i32;
    layout_glyphs(scale, font, text, |g, bb| {
        g.draw(|gx, gy, gv| {
            let gx = gx as i32 + bb.min.x;
            let gy = gy as i32 + bb.min.y;
            let image_x = gx + x;
            let image_y = gy + y;
            if (0..image_width).contains(&image_x) && (0..image_height).contains(&image_y) {
                let pixel = canvas.get_pixel(image_x as u32, image_y as u32);
                let weighted_color = weighted_sum(pixel, color, 1.0 - gv, gv);
                canvas.draw_pixel(image_x as u32, image_y as u32, weighted_color);
            }
        })
    });
}
pub fn draw_text_mut < ' a , C > ( canvas : & ' a mut C , color : C :: Pixel , x : i32 , y : i32 , scale : Scale , font : & ' a Font < ' a > , text : & ' a str , ) where C : Canvas , < C :: Pixel as Pixel > :: Subpixel : ValueInto < f32 > + Clamp < f32 > , { let image_width = canvas . width ( ) as i32 ; let image_height = canvas . height ( ) as i32 ; layout_glyphs ( scale , font , text , | g , bb | { g . draw ( | gx , gy , gv | { let gx = gx as i32 + bb . min . x ; let gy = gy as i32 + bb . min . y ; let image_x = gx + x ; let image_y = gy + y ; if ( 0 .. image_width ) . contains ( & image_x ) && ( 0 .. image_height ) . contains ( & image_y ) { let pixel = canvas . get_pixel ( image_x as u32 , image_y as u32 ) ; let weighted_color = weighted_sum ( pixel , color , 1.0 - gv , gv ) ; canvas . draw_pixel ( image_x as u32 , image_y as u32 , weighted_color ) ; } } ) } ) ; }
Draws colored text on an image in place.
Draws colored text on an image in place .
canvas
&'a mut C
color
C::Pixel
x
i32
y
i32
scale
Scale
font
&'a Font<'a>
text
&'a str
canvas
&'a mut C
color
C::Pixel
x
i32
y
i32
scale
Scale
font
&'a Font<'a>
text
&'a str