Method: PSD::Compose#multiply
- Defined in:
- lib/psd/renderer/compose.rb
#multiply(fg, bg, opts = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/psd/renderer/compose.rb', line 47 def multiply(fg, bg, opts={}) return apply_opacity(fg, opts) if fully_transparent?(bg) return bg if fully_transparent?(fg) mix_alpha, dst_alpha = calculate_alphas(fg, bg, DEFAULT_OPTS.merge(opts)) new_r = blend_channel(r(bg), r(fg) * r(bg) >> 8, mix_alpha) new_g = blend_channel(g(bg), g(fg) * g(bg) >> 8, mix_alpha) new_b = blend_channel(b(bg), b(fg) * b(bg) >> 8, mix_alpha) rgba(new_r, new_g, new_b, dst_alpha) end |