Skip to content

Commit 4b25ec8

Browse files
committed
Centering the rotating star
1 parent 9710c46 commit 4b25ec8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

SkiaSDLExample.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
#
99
# Based on Google's own Skia + SDL C++ example, chrome/m92:example/SkiaSDLExample.cpp
1010

11-
# Notable difference with the c++ version:
11+
# Notable difference (improvement!) with the c++ version:
1212
# - The instructional text "Click and drag to create rects. Press esc to quit."
1313
# is drawn so that its top left corner is the top left corner of the window.
1414
# The original draws its *bottom* left corner somewhat arbitrarily at 100,100.
15+
# - The rotating star is drawn at the centre, even if the window
16+
# is resized. The original is at a fixed position relative to the bottom left corner.
1517

1618
from sdl2 import *
1719
from sdl2.video import *
@@ -209,7 +211,7 @@ def main(argv):
209211
canvas.translate(0, -(dh.value - state.window_height))
210212

211213
canvas.save()
212-
canvas.translate(dm.w / 2.0, dm.h / 2.0)
214+
canvas.translate(state.window_width / 2.0, dh.value - state.window_height / 2.0)
213215
canvas.rotate(rotation)
214216
rotation+=1
215217
canvas.drawImage(image, -50.0, -50.0)

0 commit comments

Comments
 (0)