Skip to content

Commit f0c1847

Browse files
committed
examples: Antialias cubes and centre its title.
It never called set_antialiasing, so the wireframe and title were both hard edged. The title was also bitmap text at scale 1, which is 8 points as a vector size; at a legible size the hardcoded x no longer centres it.
1 parent 1d4922a commit f0c1847

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

examples/cubes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import time
77
from random import randint, randrange
88

9-
from picovector import color, font
9+
from picovector import color, font, image
1010

1111
from presto import Presto
1212

@@ -16,6 +16,10 @@
1616
WIDTH, HEIGHT = display.width, display.height
1717

1818
display.font = font.load("Roboto-Medium.af")
19+
display.antialias = image.X4
20+
21+
TITLE = "Flying Cubes!"
22+
TITLE_SIZE = 20
1923

2024
BLACK = color.rgb(0, 0, 0)
2125
WHITE = color.rgb(255, 255, 255)
@@ -135,7 +139,7 @@ def draw(self):
135139
display.pen = BLACK
136140
display.clear()
137141
display.pen = WHITE
138-
display.text("Flying Cubes!", 90, 110, 8)
142+
display.text(TITLE, (WIDTH - display.measure_text(TITLE, TITLE_SIZE)[0]) / 2, 110, TITLE_SIZE)
139143
display.pen = color.hsv(t * 360, 255, 255)
140144
# Now we go through each Cube object we have in 'cubes'
141145
# and increase the FOV angle so it appears closer to the screen.

0 commit comments

Comments
 (0)