[][src]Function photon_rs::colour_spaces::mix_with_colour

pub fn mix_with_colour(
    photon_image: &mut PhotonImage,
    mix_colour: Rgb,
    opacity: f32
)

Mix image with a single color, supporting passing opacity. The algorithm comes from Jimp. See function mix and function colorFn at following link: https://github.com/oliver-moran/jimp/blob/29679faa597228ff2f20d34c5758e4d2257065a3/packages/plugin-color/src/index.js Specifically, result_value = (mix_color_value - origin_value) * opacity + origin_value = mix_color_value * opacity + (1 - opacity) * origin_value for each of RGB channel.

Arguments

  • photon_image - A PhotonImage that contains a view into the image.
  • mix_color - the color to be mixed in, as an RGB value.
  • opacity - the opacity of color when mixed to image. Float value from 0 to 1.

Example

// For example, to mix an image with rgb (50, 255, 254) and opacity 0.4:
use photon::colour_spaces::mix_with_colour;

let mix_colour = Rgb{50, 255, 254};
mix_with_colour(photon_image, mix_colour, 0.4);