struct

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.

Source
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:

flower

Raises Error when an invalid color character is found in color_characters.

Source

Instance methods

draw

Inserts the pixels into the buffer.

Source
height
Source
map

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} }
Source
width
Source
x=(x : Int32)
Source
y=(y : Int32)
Source

Nested types