diff --git a/lib/xmet/hodograph.py b/lib/xmet/hodograph.py index cbf4176..ca469e9 100644 --- a/lib/xmet/hodograph.py +++ b/lib/xmet/hodograph.py @@ -21,16 +21,20 @@ def knots(ms: float) -> float: class Hodograph(): def __init__(self, width, height): + self.scale = 1.2 + self.offset_x = 0.1 + self.offset_y = 0.9 + self.width = min(width, height) self.height = min(width, height) - self.radius = min(width, height) * 1.2 + self.radius = min(width, height) * self.scale def sample_to_screen(self, wind_speed: dir, wind_dir: float) -> tuple: r = self.radius * min(wind_speed, WIND_SPEED_MAX) / WIND_SPEED_MAX return ( - 0.1 * self.width + r * math.cos(radians(wind_dir)), - 0.9 * self.height + r * math.sin(radians(wind_dir)) + self.offset_x * self.width + r * math.cos(radians(wind_dir)), + self.offset_y * self.height + r * math.sin(radians(wind_dir)) ) def draw_speed_lines(self, cr: cairo.Context, x, y): @@ -41,8 +45,8 @@ class Hodograph(): cr.set_dash([5, 5], 1) for speed in range(WIND_SPEED_MIN, WIND_SPEED_MAX+1, WIND_SPEED_STEP): - cr.arc(x + 0.1 * self.width, - y + 0.9 * self.height, + cr.arc(x + self.offset_x * self.width, + y + self.offset_y * self.height, self.radius * min(speed, WIND_SPEED_MAX) / WIND_SPEED_MAX, 0, 2*math.pi)