Last active
March 31, 2024 14:00
-
-
Save pointofpresence/c3e873afb04a14d9d1624ef78d1bb2de to your computer and use it in GitHub Desktop.
Python: Текст по центру холста (Cairo)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL) | |
| context.set_font_size(52.0) | |
| (x, y, width, height, dx, dy) = context.text_extents("Hello") | |
| context.move_to(WIDTH/2. - width/2., HEIGHT/2. + height/2.) | |
| context.show_text("Hello") | |
| """ | |
| Указанный код рисует текст "Hello" по центру холста, выравнивая его горизонтально и вертикально | |
| с использованием информации о геометрии текста (width, height, dx, dy), полученной из text_extents. | |
| """ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment