Erstveröffentlichung Weihnachten 2024
This commit is contained in:
119
pages/windrose.py
Normal file
119
pages/windrose.py
Normal file
@@ -0,0 +1,119 @@
|
||||
"""
|
||||
|
||||
Windrose und Windroseflex
|
||||
Benötigt 6 Werte
|
||||
Hauptwerte: AWA, AWS, TWD, TWS
|
||||
Nebenwerte: DBT, STW, oder COG, SOG
|
||||
|
||||
"""
|
||||
|
||||
import cairo
|
||||
import math
|
||||
from .page import Page
|
||||
|
||||
class WindRose(Page):
|
||||
|
||||
def draw(self, ctx):
|
||||
|
||||
# Rahmen
|
||||
cx = 200
|
||||
cy = 150
|
||||
r = 110
|
||||
|
||||
ctx.set_line_width(3)
|
||||
ctx.arc(cx, cy, r + 9, 0, 2*math.pi)
|
||||
ctx.stroke()
|
||||
ctx.arc(cx, cy, r - 11, 0, 2*math.pi)
|
||||
ctx.stroke()
|
||||
|
||||
for angle in range(0, 360, 10):
|
||||
if angle % 30 != 0:
|
||||
x, y = self.rotate((cx, cy), ((cx, cy - r),), angle)[0]
|
||||
ctx.arc(x, y, 2, 0, 2*math.pi)
|
||||
ctx.fill()
|
||||
else:
|
||||
p = ((cx, cy - r + 10), (cx, cy - r - 10), (cx, cy - r + 30))
|
||||
pr = self.rotate((cx, cy), p, angle)
|
||||
ctx.move_to(*pr[0])
|
||||
ctx.line_to(*pr[1])
|
||||
ctx.stroke()
|
||||
self.draw_text_center(ctx, *pr[2], str(angle))
|
||||
|
||||
|
||||
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
||||
|
||||
# Namen
|
||||
ctx.set_font_size(24)
|
||||
ctx.move_to(10, 95) # links oben
|
||||
ctx.show_text("AWA")
|
||||
ctx.move_to(335, 95) # rechts oben
|
||||
ctx.show_text("TWD")
|
||||
ctx.move_to(10, 220) # links unten
|
||||
ctx.show_text("AWS")
|
||||
ctx.move_to(335, 220) # rechts unten
|
||||
ctx.show_text("TWS")
|
||||
|
||||
# Units
|
||||
ctx.set_font_size(16)
|
||||
ctx.move_to(10, 115) # links oben
|
||||
ctx.show_text("Deg")
|
||||
ctx.move_to(335, 115) # rechts oben
|
||||
ctx.show_text("Deg")
|
||||
ctx.move_to(10, 190) # links unten
|
||||
ctx.show_text("kn")
|
||||
ctx.move_to(335, 190) # rechts unten
|
||||
ctx.show_text("kn")
|
||||
|
||||
# Horiz. Trennlinien
|
||||
#ctx.rectangle(0, 149, 60, 3)
|
||||
#ctx.fill()
|
||||
ctx.set_line_width(3)
|
||||
# links
|
||||
ctx.move_to(0, 149)
|
||||
ctx.line_to(60, 149)
|
||||
# rechts
|
||||
ctx.move_to(340, 149)
|
||||
ctx.line_to(400, 149)
|
||||
ctx.stroke()
|
||||
|
||||
# Meßwerte
|
||||
ctx.select_font_face("DSEG7 Classic")
|
||||
ctx.set_font_size(40)
|
||||
# links oben
|
||||
ctx.move_to(10, 65)
|
||||
ctx.show_text("148")
|
||||
# rechts oben
|
||||
ctx.move_to(295, 65)
|
||||
ctx.show_text("---")
|
||||
# links unten
|
||||
ctx.move_to(10, 270)
|
||||
ctx.show_text("46.7")
|
||||
# rechts unten
|
||||
ctx.move_to(295, 270)
|
||||
ctx.show_text("77.8")
|
||||
|
||||
ctx.set_font_size(32)
|
||||
# innen oben
|
||||
ctx.move_to(160, 130)
|
||||
ctx.show_text("38.9")
|
||||
# innen unten
|
||||
ctx.move_to(160, 200)
|
||||
ctx.show_text("19.9")
|
||||
ctx.stroke()
|
||||
|
||||
|
||||
# Zeiger
|
||||
angle = 148
|
||||
p = ((cx - 1, cy - (r - 15)), (cx + 1, cy - (r - 15)), (cx + 4, cy), (cx - 4, cy))
|
||||
zeiger = self.rotate((cx, cy), p, angle)
|
||||
ctx.move_to(*zeiger[0])
|
||||
for point in zeiger[1:]:
|
||||
ctx.line_to(*point)
|
||||
ctx.fill()
|
||||
|
||||
ctx.set_source_rgb(*self.bgcolor)
|
||||
ctx.arc(cx, cy, 8, 0, 2*math.pi)
|
||||
ctx.fill()
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ctx.arc(cx, cy, 7, 0, 2*math.pi)
|
||||
ctx.fill()
|
||||
Reference in New Issue
Block a user