Closed
Description
In order to reduce the amount of memory for displaying text, @FoamyGuy and I are developing a new "label" class that will use a bitmap instead of a group of TileGrids to store the text. Here is a proposed strategy for this new "bitmap_label" Class:
bitmap_label
Class definition
-
Input parameters:
- Make
text
a required parameter (Note: This will flag if someone creates a bitmap_label with no text, which doesn’t make any sense.) - For direct compatibility with label, keep the
max_glyphs
parameter, but ignore it.
- Make
-
Do we want to keep self._memorySaver? (Note: If so, update this to a class variable)
- True - do not save the text value
- False - save the text value
- If we keep this option, then we need to create a getter for text, returns
None
if self._memorySaver == True.
-
Since the bitmap_label has limited edit capability after creation, minimize the instance variables that are stored
-
Add getters/setters for:
- anchor_point
- anchor_position
- color
- background_color
- bounding_box (x,y, w,h)
-
Getters only (or does it regenerate from scratch if this is changed?)
- font
- line_spacing
- text (returns None if text is not stored with
_memory_saver
option)
-
Add scale capability (this should be handled in the Group)
General steps for _init_
of a bitmap_label instance:
- Error-checking: If text is “”, raise an exception.
- Calculate the text box size, including any newlines and tabs
- Calculate the background box size, including padding
Note: Negative padding cannot be used. (This would require adding a third color to the palette, which would inflate the bitmap_label bitmap memory usage.) - Determine the bitmap size required by comparing the text box and background box max x,y dimensions.
- Determine start location of text in the bitmap
- Initialize the palette, TileGrid (self), Bitmap
- Draw the background fill, as required
- Place the text in the bitmap
- Set the TileGrid x,y placement based on anchor_point and anchor_position.
- Updated
bounding_box
values.