Module: ColorContrastCalc::Converter::AlphaCompositing
- Defined in:
- lib/color_contrast_calc/converter.rb
Defined Under Namespace
Modules: Rgba
Class Method Summary collapse
-
.compose(foreground, background, base = Rgba::WHITE) ⇒ Hash
Return a pair of RGBA colors created from two other RGBA colors placed on a base color.
Class Method Details
.compose(foreground, background, base = Rgba::WHITE) ⇒ Hash
Return a pair of RGBA colors created from two other RGBA colors placed on a base color.
The calculation is based on the definition found at www.w3.org/TR/compositing-1/#simplealphacompositing
50 51 52 53 54 55 56 57 58 |
# File 'lib/color_contrast_calc/converter.rb', line 50 def self.compose(foreground, background, base = Rgba::WHITE) back = calc(background, base) fore = calc(foreground, back) { foreground: normalize(fore), background: normalize(back) } end |