MCPcopy
hub / github.com/anthonynsimon/bild / alphaComp

Function alphaComp

blend/blend.go:379–389  ·  view source on GitHub ↗

alphaComp returns a new color after compositing the two colors based on the foreground's alpha channel.

(bg, fg fcolor.RGBAF64)

Source from the content-addressed store, hash-verified

377// alphaComp returns a new color after compositing the two colors
378// based on the foreground's alpha channel.
379func alphaComp(bg, fg fcolor.RGBAF64) fcolor.RGBAF64 {
380 fg.Clamp()
381 fga := fg.A
382
383 r := (fg.R * fga / 1) + ((1 - fga) * bg.R / 1)
384 g := (fg.G * fga / 1) + ((1 - fga) * bg.G / 1)
385 b := (fg.B * fga / 1) + ((1 - fga) * bg.B / 1)
386 a := bg.A + fga
387
388 return fcolor.RGBAF64{R: r, G: g, B: b, A: a}
389}

Callers 15

NormalFunction · 0.85
AddFunction · 0.85
MultiplyFunction · 0.85
OverlayFunction · 0.85
SoftLightFunction · 0.85
ScreenFunction · 0.85
DifferenceFunction · 0.85
DivideFunction · 0.85
ColorBurnFunction · 0.85
ExclusionFunction · 0.85
ColorDodgeFunction · 0.85
LinearBurnFunction · 0.85

Calls 1

ClampMethod · 0.80

Tested by

no test coverage detected