Method: PSD::Compose#exclusion

Defined in:
lib/psd/renderer/compose.rb

#exclusion(fg, bg, opts = {}) ⇒ Object



313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/psd/renderer/compose.rb', line 313

def exclusion(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(bg) + r(fg) - (r(bg) * r(fg) >> 7), mix_alpha)
  new_g = blend_channel(g(bg), g(bg) + g(fg) - (g(bg) * g(fg) >> 7), mix_alpha)
  new_b = blend_channel(b(bg), b(bg) + b(fg) - (b(bg) * b(fg) >> 7), mix_alpha)

  rgba(new_r, new_g, new_b, dst_alpha)
end