|
51 | 51 | "SSD1306 ORGANIC LED DISPLAY. THIS IS AN OLD SCHOOL DEMO SCROLLER!!"
|
52 | 52 | + "GREETZ TO: LADYADA & THE ADAFRUIT CREW, TRIXTER, FUTURE CREW, AND FARBRAUSCH"
|
53 | 53 | )
|
54 |
| -maxwidth, unused = draw.textsize(text, font=font) |
| 54 | +bbox = draw.textbbox((0,0), text, font=font) |
| 55 | +maxwidth = bbox[2] - bbox[0] |
55 | 56 |
|
56 | 57 | # Set animation and sine wave parameters.
|
57 | 58 | amplitude = height / 4
|
|
73 | 74 | break
|
74 | 75 | # Calculate width but skip drawing if off the left side of screen.
|
75 | 76 | if x < -10:
|
76 |
| - char_width, char_height = draw.textsize(c, font=font) |
| 77 | + bbox = draw.textbbox((0,0), c, font=font) |
| 78 | + char_width, char_height = bbox[2] - bbox[0], bbox[3] - bbox[1] |
77 | 79 | x += char_width
|
78 | 80 | continue
|
79 | 81 | # Calculate offset from sine wave.
|
80 | 82 | y = offset + math.floor(amplitude * math.sin(x / float(width) * 2.0 * math.pi))
|
81 | 83 | # Draw text.
|
82 | 84 | draw.text((x, y), c, font=font, fill=255)
|
83 | 85 | # Increment x position based on chacacter width.
|
84 |
| - char_width, char_height = draw.textsize(c, font=font) |
| 86 | + bbox = draw.textbbox((0,0), c, font=font) |
| 87 | + char_width, char_height = bbox[2] - bbox[0], bbox[3] - bbox[1] |
85 | 88 | x += char_width
|
86 | 89 |
|
87 | 90 | # Draw the image buffer.
|
|
0 commit comments