Package rstem :: Package led_matrix :: Class LEDSprite
[hide private]
[frames] | no frames]

Class LEDSprite

source code

object --+
         |
        LEDSprite
Known Subclasses:

Allows the creation of a LED Sprite that is defined in a text file.


Notes:
Instance Methods [hide private]
 
__init__(self, filename=None, height=0, width=0, color=0)
Creates a LEDSprite object from the given .spr file or image file or creates an empty sprite of given height and width if filename == None.
source code
 
append(self, sprite)
Appends given sprite to the right of itself.
source code
 
set_pixel(self, point, color=15)
Sets given color to given x and y coordinate in sprite
source code
int
get_pixel(self, x, y)
Returns: int of color at given origin or None
source code
 
save_to_file(self, filename)
Saves sprite bitmap to given .spr file.
source code
LEDSprite
rotate(self, angle=90)
Rotates sprite at 90 degree intervals.
source code
LEDSprite
rotated(self, angle=90)
Same as rotate only it returns a copy of the rotated sprite and does not affect the original.
source code
LEDSprite
copy(self)
Copies sprite
source code
LEDSprite
invert(self)
Inverts the sprite.
source code
LEDSprite
inverted(self)
Same as invert only it returns a copy of the inverted sprite and does not affect the original.
source code
LEDSprite
flip_horizontal(self)
Flips the sprite horizontally.
source code
LEDSprite
flipped_horizontal(self)
Same as flip_horizontal only it returns a copy of the flipped sprite and does not affect the original.
source code
LEDSprite
flip_vertical(self)
Flips the sprite vertically.
source code
LEDSprite
flipped_vertical(self)
Same as flip_vertical only it returns a copy of the flipped sprite and does not affect the original.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  width
  height

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename=None, height=0, width=0, color=0)
(Constructor)

source code 

Creates a LEDSprite object from the given .spr file or image file or creates an empty sprite of given height and width if filename == None.

Parameters:
  • filename - The full path location of a .spr sprite file or image file
  • height (int) - The height of given sprite if creating an empty sprite or want to resize a sprite from and image file.
  • width (int) - The width of given sprite if creating an empty sprite or want to resize a sprite from and image file.
  • color (int or string (0-F or 16 or '-' for transparent)) - Color to display at point
Overrides: object.__init__

append(self, sprite)

source code 

Appends given sprite to the right of itself.

Parameters:

Note: height of given sprite must be <= to itself otherwise will be truncated

set_pixel(self, point, color=15)

source code 

Sets given color to given x and y coordinate in sprite

Parameters:
  • point ((x,y)) - point relative to sprite to set point
  • color (int or string (0-F or 16 or '-' for transparent)) - Color to display at point
Returns:
None if coordinate is not valid

get_pixel(self, x, y)

source code 
Returns: int
int of color at given origin or None

save_to_file(self, filename)

source code 

Saves sprite bitmap to given .spr file.

Parameters:
  • filename (string) - relative filename path

Note: It will truncate filename if it already exists.

rotate(self, angle=90)

source code 

Rotates sprite at 90 degree intervals.

Parameters:
  • angle (int) - angle to rotate self in an interval of 90 degrees
Returns: LEDSprite
self
Raises:
  • ValueError - If angle is not multiple of 90

Note: If no angle given, will rotate sprite 90 degrees.

rotated(self, angle=90)

source code 

Same as rotate only it returns a copy of the rotated sprite and does not affect the original.

Returns: LEDSprite
Rotated sprite

copy(self)

source code 

Copies sprite

Returns: LEDSprite
A copy of sprite without affecting original sprite

invert(self)

source code 

Inverts the sprite.

Returns: LEDSprite
self

inverted(self)

source code 

Same as invert only it returns a copy of the inverted sprite and does not affect the original.

Returns: LEDSprite
Inverted sprite

flip_horizontal(self)

source code 

Flips the sprite horizontally.

Returns: LEDSprite
self

flipped_horizontal(self)

source code 

Same as flip_horizontal only it returns a copy of the flipped sprite and does not affect the original.

Returns: LEDSprite
sprite flipped horizontally

flip_vertical(self)

source code 

Flips the sprite vertically.

Returns: LEDSprite
self

flipped_vertical(self)

source code 

Same as flip_vertical only it returns a copy of the flipped sprite and does not affect the original.

Returns: LEDSprite
sprite flipped vertically

Property Details [hide private]

width

Get Method:
unreachable.width(self)

height

Get Method:
unreachable.height(self)