Method: PSD::Compose#normal
- Defined in:
- lib/psd/compose.rb
#normal(fg, bg, opts = {}) ⇒ Object
Normal composition, delegate to ChunkyPNG
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/psd/compose.rb', line 19 def normal(fg, bg, opts={}) return fg if opaque?(fg) || 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), mix_alpha) new_g = blend_channel(g(bg), g(fg), mix_alpha) new_b = blend_channel(b(bg), b(fg), mix_alpha) rgba(new_r, new_g, new_b, dst_alpha) end |