Skip to main content

draw_border

Function draw_border 

Source
pub fn draw_border(
    image: &RgbaImage,
    border: &Border,
    apply_opacity: bool,
) -> (RgbaImage, u32)
Expand description

Draw a border around image (straight alpha, 8 bit). The result is larger by the border’s reach on every side; the second value is that margin, to move the image’s origin by.

The border’s alpha at a pixel is the largest a(q) · k(|p − q|) over the layer’s pixels q, with k(d) = clamp(width + 1.5 − d, 0, 1) (pixel centres; a binarised when the border ignores the layer’s alpha). The layer is drawn over its border, and the border only fills the alpha up to that value: the result’s alpha is max(a, border).