Skip to content

Commit 546df7d

Browse files
authored
Update SkiaGLFWExample-v4.py
Skip to content Navigation Menu Copilot Copilot navigation Copilot Chat New conversation You said: In https://github.com/HinTak/skia-python-examples/blob/main/SkiaGLFWExample-v4.py , the text display should In https://github.com/HinTak/skia-python-examples/blob/main/SkiaGLFWExample-v4.py , the text display should be at the top left corner. Can you suggest a fix? 3/3 1 reference Copilot said: The issue with the text display being The issue with the text display being at the bottom instead of the top is related to the canvas.translate function in the main() function. Specifically, this code: Python canvas.translate(0, state.window_height - font.getSize()) This line places the text at the bottom of the window due to the subtraction of font.getSize() from state.window_height, essentially offsetting the text to the bottom. To fix this and display the text at the top-left corner, you should remove the translation offset and directly draw the text at (0, 0). Here's the updated code snippet: Python # Draw help message paint.setColor(ColorBLACK) canvas.save() # Remove the translation to the bottom canvas.translate(0, 0) canvas.drawString(helpMessage, 0, font.getSize(), font, paint) canvas.restore() With this modification, the help message will be displayed at the top-left corner of the window. Ask Copilot 1 reference Copilot said: The issue with the text display being The issue with the text display being at the bottom instead of the top is related to the canvas.translate function in the main() function. Specifically, this code: Python canvas.translate(0, state.window_height - font.getSize()) This line places the text at the bottom of the window due to the subtraction of font.getSize() from state.window_height, essentially offsetting the text to the bottom. To fix this and display the text at the top-left corner, you should remove the translation offset and directly draw the text at (0, 0). Here's the updated code snippet: Python # Draw help message paint.setColor(ColorBLACK) canvas.save() # Remove the translation to the bottom canvas.translate(0, 0) canvas.drawString(helpMessage, 0, font.getSize(), font, paint) canvas.restore() With this modification, the help message will be displayed at the top-left corner of the window.
1 parent 60a2dab commit 546df7d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

SkiaGLFWExample-v4.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def on_window_size(window, w, h):
140140
# Draw help message
141141
paint.setColor(ColorBLACK)
142142
canvas.save()
143-
canvas.translate(0, state.window_height - font.getSize())
143+
canvas.translate(0, 0)
144144
canvas.drawString(helpMessage, 0, font.getSize(), font, paint)
145145
canvas.restore()
146146

0 commit comments

Comments
 (0)