struct Lime::Drawables::Pixels
- Lime::Drawables::Pixels
- Struct
- Value
- Object
Overview
A drawable sequence of pixels.
Defined in:
lime/drawables.crConstructors
-
.new(path : String, x : Int32, y : Int32)
Initializes new
Pixels
from an image. -
.new(x : Int32, y : Int32, color_characters : String)
Initializes new
Pixels
from a string.
Instance Method Summary
-
#draw
Inserts the pixels into the buffer.
- #height : Int32
-
#map(&)
Invokes the given block for each of the pixels, replacing the pixel with the pixel returned by the block.
- #width : Int32
- #x : Int32
- #x=(x : Int32)
- #y : Int32
- #y=(y : Int32)
Constructor Detail
Initializes new Pixels
from an image.
path must lead to an PNG-encoded image.
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 Method Detail
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} }