lib/chunky_png/canvas/masking.rb
# Changes the color of a mask image.
#
# This method works on a canvas extracted out of another image using the {#extract_mask} method.
# It can then be applied on the extracted base image. See {#change_theme_color!} to perform
# these operations in one go.
#
# @param [Integer] new_color The color to replace the original mask color with.
# @raise [ChunkyPNG::ExpectationFailed] when this canvas is not a mask image, i.e. its palette
#    has more than once color, disregarding transparency.
# @see #change_theme_color!
# @see #extract_mask
Changes the color of a mask image.
This method works on a canvas extracted out of another image using the {#extract_mask} method.
It can then be applied on the extracted base image. See {#change_theme_color!} to perform
these operations in one go.
Changes the color of a mask image . This method works on a canvas extracted out of another image using the { #extract_mask } method . It can then be applied on the extracted base image . See { #change_theme_color! } to perform these operations in one go .
def change_mask_color!(new_color)
        raise ChunkyPNG::ExpectationFailed, "This is not a mask image!" if palette.opaque_palette.size != 1
        pixels.map! { |pixel| (new_color & 0xffffff00) | ChunkyPNG::Color.a(pixel) }
        self
      end
def change_mask_color! ( new_color ) raise ChunkyPNG :: ExpectationFailed , "This is not a mask image!" if palette . opaque_palette . size != 1 pixels . map! { | pixel | ( new_color & 0xffffff00 ) | ChunkyPNG :: Color . a ( pixel ) } self end
Changes the color of a mask image.
Changes the color of a mask image .
[ChunkyPNG::ExpectationFailed] when this canvas is not a mask image, i.e. its palette has more than once color, disregarding transparency.
[ ChunkyPNG :: ExpectationFailed ] when this canvas is not a mask image i . e . its palette has more than once color disregarding transparency .
new_color
<not_specific>
<not_specific>
new_color The color to replace the original mask color with.
new_color The color to replace the original mask color with .
see
None
see
None