Skip to content

Commit a47aec7

Browse files
committed
add scale. fix algin property name in ex json. implement color and background_color
1 parent dd7617b commit a47aec7

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

adafruit_slideshow.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,11 @@ def _fade_down(self):
332332

333333
def _create_label(self, file):
334334
json_data = json.loads(file.read())
335-
label = bitmap_label.Label(terminalio.FONT, text=json_data['text'])
335+
_scale = 1
336+
if "scale" in json_data:
337+
_scale = int(json_data["scale"])
338+
339+
label = bitmap_label.Label(terminalio.FONT, text=json_data['text'], scale=_scale)
336340
if "h_align" not in json_data or json_data["h_align"] == "LEFT":
337341
x_anchor_point = 0.0
338342
x_anchored_position = 0
@@ -361,6 +365,12 @@ def _create_label(self, file):
361365
y_anchor_point = 0.0
362366
y_anchored_position = 0
363367

368+
if "background_color" in json_data:
369+
label.background_color = int(json_data["background_color"], 16)
370+
371+
if "color" in json_data:
372+
label.color = int(json_data["color"], 16)
373+
364374
label.anchor_point = (x_anchor_point, y_anchor_point)
365375
label.anchored_position = (x_anchored_position, y_anchored_position)
366376
return label
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"text": "Sample Text\nSlideshow",
3-
"h_alignment": "CENTER",
4-
"v_alignment": "CENTER",
3+
"h_align": "CENTER",
4+
"v_align": "CENTER",
55
"color": "0x0000FF",
6-
"background_color": "0xFF00FF"
6+
"background_color": "0xFF00FF",
7+
"scale": 2
78
}

0 commit comments

Comments
 (0)