def decompose_color(color, mask, bg, tolerance = 1)
      if alpha_decomposable?(color, mask, bg, tolerance)
        mask & 0xffffff00 | decompose_alpha(color, mask, bg)
      else
        mask & 0xffffff00
      end
    end
def decompose_color(color, mask, bg, tolerance = 1)
      if alpha_decomposable?(color, mask, bg, tolerance)
        mask & 0xffffff00 | decompose_alpha(color, mask, bg)
      else
        mask & 0xffffff00
      end
    end
Decomposes a color, given a color, a mask color and a background color.
 The returned color will be a variant of the mask color, with the alpha
 channel set to the best fitting value. This basically is the reverse
 operation if alpha composition.

 If the color cannot be decomposed, this method will return the fully
 transparent variant of the mask color.

 @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 [Integer] The decomposed color, a variant of the masked color
   with the alpha channel set to an appropriate value.