lib/chunky_png/color.rb
# Composes two colors with an alpha channel using integer math.
#
# This version is faster than the version based on floating point math, so
# this compositing function is used by default.
#
# @param [Integer] fg The foreground color.
# @param [Integer] bg The background color.
# @return [Integer] The composited color.
# @see ChunkyPNG::Color#compose_precise
Composes two colors with an alpha channel using integer math.
This version is faster than the version based on floating point math, so
this compositing function is used by default.
Composes two colors with an alpha channel using integer math . This version is faster than the version based on floating point math so this compositing function is used by default .
def compose_quick(fg, bg)
      return fg if opaque?(fg) || fully_transparent?(bg)
      return bg if fully_transparent?(fg)
      a_com = int8_mult(0xff - a(fg), a(bg))
      new_r = int8_mult(a(fg), r(fg)) + int8_mult(a_com, r(bg))
      new_g = int8_mult(a(fg), g(fg)) + int8_mult(a_com, g(bg))
      new_b = int8_mult(a(fg), b(fg)) + int8_mult(a_com, b(bg))
      new_a = a(fg) + a_com
      rgba(new_r, new_g, new_b, new_a)
    end
def compose_quick ( fg , bg ) return fg if opaque? ( fg ) || fully_transparent? ( bg ) return bg if fully_transparent? ( fg ) a_com = int8_mult ( 0xff - a ( fg ) , a ( bg ) ) new_r = int8_mult ( a ( fg ) , r ( fg ) ) + int8_mult ( a_com , r ( bg ) ) new_g = int8_mult ( a ( fg ) , g ( fg ) ) + int8_mult ( a_com , g ( bg ) ) new_b = int8_mult ( a ( fg ) , b ( fg ) ) + int8_mult ( a_com , b ( bg ) ) new_a = a ( fg ) + a_com rgba ( new_r , new_g , new_b , new_a ) end
Composes two colors with an alpha channel using integer math.
Composes two colors with an alpha channel using integer math .
The composited color.
The composited color .
Integer
fg
<not_specific>
bg
<not_specific>
<not_specific>
bg The background color.
bg The background color .
see
None