def label_pos(self, pos, label=None, horizontal=False):
"""Calculate label start position (top-right if vertical, top-center if horizontal)"""
xscale = turtle.getscreen().xscale
yscale = turtle.getscreen().yscale
font_family, font_size = self.font
font = Font(family=font_family, size=font_size)
line_height = font.metrics('linespace') / yscale
height = (label.count('\n') + 1) * line_height
return -8 / xscale if horizontal else pos, \
pos - 0.5 * height if horizontal else -height - 6 / yscale
评论列表
文章目录