lib/chunky_png/color.rb
# Checks whether an alpha channel value can successfully be composed
# given the resulting color, the mask color and a background color,
# all of which should be opaque.
#
# @param [Integer] color The color that was the result of compositing.
# @param [Integer] mask The opaque variant of the color that was being
#   composed
# @param [Integer] bg The background color on which the color was composed.
# @param [Integer] tolerance The decomposition tolerance level, a value
#   between 0 and 255.
# @return [Boolean] True if the alpha component can be decomposed
#   successfully.
# @see #decompose_alpha
Checks whether an alpha channel value can successfully be composed
given the resulting color, the mask color and a background color,
all of which should be opaque.
Checks whether an alpha channel value can successfully be composed given the resulting color the mask color and a background color all of which should be opaque .
def alpha_decomposable?(color, mask, bg, tolerance = 1)
      components = decompose_alpha_components(color, mask, bg)
      sum = components.inject(0) { |a, b| a + b }
      max = components.max * 3
      components.max <= 255 && components.min >= 0 && (sum + tolerance * 3) >= max
    end
def alpha_decomposable? ( color , mask , bg , tolerance = 1 ) components = decompose_alpha_components ( color , mask , bg ) sum = components . inject ( 0 ) { | a , b | a + b } max = components . max * 3 components . max <= 255 && components . min >= 0 && ( sum + tolerance * 3 ) >= max end
Checks whether an alpha channel value can successfully be composed
given the resulting color, the mask color and a background color,
all of which should be opaque.
Checks whether an alpha channel value can successfully be composed given the resulting color the mask color and a background color all of which should be opaque .
True if the alpha component can be decomposed successfully.
True if the alpha component can be decomposed successfully .
Boolean
color
<not_specific>
mask
<not_specific>
bg
<not_specific>
tolerance
<not_specific>
<not_specific>
tolerance The decomposition tolerance level, a value between 0 and 255.
tolerance The decomposition tolerance level a value between 0 and 255 .
see
None