lib/chunky_png/palette.rb in chunky_png-0.5.8 vs lib/chunky_png/palette.rb in chunky_png-0.6.0
- old
+ new
@@ -87,9 +87,16 @@
# @return [true, false] True if all colors in this palette are grayscale teints.
# @see ChunkyPNG::Color#grayscale??
def grayscale?
all? { |color| Color.grayscale?(color) }
end
+
+ # Returns a palette with all the opaque variants of the colors in this palette.
+ # @return [ChunkyPNG::Palette] A new Palette instance with only opaque colors.
+ # @see ChunkyPNG::Color#opaque!
+ def opaque_palette
+ self.class.new(map { |c| ChunkyPNG::Color.opaque!(c) })
+ end
# Checks whether this palette is suitable for decoding an image from a datastream.
#
# This requires that the positions of the colors in the original palette chunk is known,
# which is stored as an array in the +@decoding_map+ instance variable.