Compare commits
3 commits
df0b885447
...
6a00aad2a1
Author | SHA1 | Date | |
---|---|---|---|
6a00aad2a1 | |||
59a82534dc | |||
0eecc40839 |
1 changed files with 44 additions and 2 deletions
|
@ -113,8 +113,50 @@ class Hodograph():
|
||||||
|
|
||||||
cr.move_to(x + sx + extents.width * 0.25,
|
cr.move_to(x + sx + extents.width * 0.25,
|
||||||
y + sy - extents.height * 1.5)
|
y + sy - extents.height * 1.5)
|
||||||
|
|
||||||
|
cr.show_text(text)
|
||||||
|
|
||||||
|
cr.restore()
|
||||||
|
|
||||||
|
def draw_direction_legends(self, cr: cairo.Context, x, y):
|
||||||
|
cx, cy = self.sample_to_screen(0, 0)
|
||||||
|
|
||||||
|
legends = {
|
||||||
|
'0°': (
|
||||||
|
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.show_text(text)
|
||||||
cr.stroke()
|
|
||||||
|
|
||||||
cr.restore()
|
cr.restore()
|
||||||
|
|
||||||
|
@ -263,7 +305,6 @@ class Hodograph():
|
||||||
|
|
||||||
cr.move_to(offset + x - extents.width / 4, y + 3.5*width)
|
cr.move_to(offset + x - extents.width / 4, y + 3.5*width)
|
||||||
cr.show_text(text)
|
cr.show_text(text)
|
||||||
cr.stroke()
|
|
||||||
|
|
||||||
offset += interval
|
offset += interval
|
||||||
|
|
||||||
|
@ -279,6 +320,7 @@ class Hodograph():
|
||||||
self.draw_sounding(cr, x, y, sounding)
|
self.draw_sounding(cr, x, y, sounding)
|
||||||
|
|
||||||
self.draw_speed_legends(cr, x, y)
|
self.draw_speed_legends(cr, x, y)
|
||||||
|
self.draw_direction_legends(cr, x, y)
|
||||||
self.draw_height_legends(cr, x, y)
|
self.draw_height_legends(cr, x, y)
|
||||||
|
|
||||||
cr.reset_clip()
|
cr.reset_clip()
|
||||||
|
|
Loading…
Add table
Reference in a new issue