Compare commits

..

3 commits

View file

@ -113,8 +113,50 @@ class Hodograph():
cr.move_to(x + sx + extents.width * 0.25,
y + sy - extents.height * 1.5)
cr.show_text(text)
cr.stroke()
cr.restore()
def draw_direction_legends(self, cr: cairo.Context, x, y):
cx, cy = self.sample_to_screen(0, 0)
legends = {
'': (
lambda e: x + cx - e.width / 2,
lambda e: y + self.height - 2 * e.height
),
'90°': (
lambda e: x + cx - e.width * 2,
lambda e: y + cy + e.height / 2
),
'180°': (
lambda e: x + cx - e.width / 2,
lambda e: y + 2 * e.height
),
'270°': (
lambda e: x + self.width - e.width * 2,
lambda e: y + cy + e.height / 2
)
}
cr.save()
cr.select_font_face('Sans',
cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_BOLD)
cr.set_font_size(14)
for text in legends:
extents = cr.text_extents(text)
fx, fy = legends[text]
cr.move_to(fx(extents), fy(extents))
cr.show_text(text)
cr.restore()
@ -263,7 +305,6 @@ class Hodograph():
cr.move_to(offset + x - extents.width / 4, y + 3.5*width)
cr.show_text(text)
cr.stroke()
offset += interval
@ -279,6 +320,7 @@ class Hodograph():
self.draw_sounding(cr, x, y, sounding)
self.draw_speed_legends(cr, x, y)
self.draw_direction_legends(cr, x, y)
self.draw_height_legends(cr, x, y)
cr.reset_clip()