expression

Model source-over RGB blending against an opaque background

With straight-alpha source RGB, an opaque destination and the indicated blend factors, the resulting RGB is a weighted mixture. The example uses linear-light values and assumes no color-space conversion. For translucent destinations and premultiplied representations, use the appropriate full equations and factors. Expected result (NOT RUN): 0.25, 0.00, 0.75 Common mistake: Using straight-alpha blend factors with already premultiplied RGB, or mixing encoded sRGB values as though they were linear light. Static Rust example; not a verified ByteMind executable assessment.

Formal Syntax & Structure

rust syntaxrust
out = src * alpha + dst * (1.0 - alpha)

Working Example

Example Snippetrust
fn main() {    let src=[1.0f32,0.0,0.0]; let dst=[0.0f32,0.0,1.0]; let a=0.25;    let rgb: [f32;3]=std::array::from_fn(|i| src[i]*a+dst[i]*(1.0-a));    println!("{:.2}, {:.2}, {:.2}",rgb[0],rgb[1],rgb[2]);}
Rust Reference