Lime::Drawables::Pixels
Inherits Struct < Value < Object
A drawable sequence of pixels.
Constructors
new(path : String, x : Int32, y : Int32)
Initializes new Pixels from an image.
path must lead to an PNG-encoded image.
new(x : Int32, y : Int32, color_characters : String)
Initializes new Pixels from a string.
Iterates through every character of color_characters and every time a color character is found, it's replaced with its color.
Available color characters are:
'1': default'0': black'9': dark gray'6': light gray'w': white'r': red'g': green'b': blue'y': yellow'm': magenta'c': cyan'R': light red'G': light green'B': light blue'Y': light yellow'M': light magenta'C': light cyan
Comments are also allowed in the string.
Example string:
# A flower:
RRR
RYYYR # Head
RRR
g
G g G
GGgGG # Stem
GgG
g
becomes:

Raises Error when an invalid color character is found in color_characters.
Instance methods
height
Sourcemap
Invokes the given block for each of the pixels, replacing the pixel with the pixel returned by the block.
The block must return a Tuple(UInt8, UInt8, UInt8).
# Invert colors of an image:
image.map { |pixel| {255u8 - pixel.red, 255u8 - pixel.green, 255u8 - pixel.blue} }
width
Sourcex=(x : Int32)
Sourcey=(y : Int32)
Source