oreobi.blogg.se

Blend colors
Blend colors













blend colors

If (r.A - bg.A < -1.0e-6) return null // No result - 'bg' can't make the result more transparent If (1 - bg.A <= 1.0e-6) return null // No result - 'bg' is fully opaque

blend colors

If (r.A - fg.A < -1.0e-6) return null // No result - 'fg' can't make the result more transparent If (1 - fg.A <= 1.0e-6) return null // No result - 'fg' is fully opaque You could also reverse these formulas: var bg = new Color() įor example, 50% red on top of 50% green: // background, 50% green You have to divide or multiply by 255 if you want to use values in the range. NOTE: All variables used here are in the range. 1.0e-6 is just a really small number, to compensate for rounding errors. R.B = fg.B * fg.A / r.A + bg.B * bg.A * (1 - fg.A) / r.A įg is the paint color. If (r.A < 1.0e-6) return r // Fully transparent - R,G,B not important To blend using alpha channels, you can use these formulas: r = new Color()















Blend colors