Skip to content

Commit

Permalink
feat: add illustration for special tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohongxuan committed Aug 15, 2024
1 parent 6240702 commit 2b8079b
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions run_page/gpxtrackposter/poster.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self):
"special": "#FFFF00",
"track": "#4DD2FF",
}
self.special_distance = {"special_distance1": "10", "special_distance2": "20"}
self.special_distance = {"special_distance": 10, "special_distance2": 20}
self.width = 200
self.height = 300
self.years = None
Expand Down Expand Up @@ -155,6 +155,9 @@ def __draw_footer(self, d):
value_style = "font-size:9px; font-family:Arial"
small_value_style = "font-size:3px; font-family:Arial"

special_distance1 = self.special_distance["special_distance"]
special_distance2 = self.special_distance["special_distance2"]

(
total_length,
average_length,
Expand All @@ -179,6 +182,43 @@ def __draw_footer(self, d):
style=value_style,
)
)


d.add(
d.text(
self.trans("SPECIAL TRACKS"),
insert=(65, self.height - 20),
fill=text_color,
style=header_style,
)
)

d.add(
d.rect((65, self.height - 17), (2.6, 2.6), fill=self.colors["special"])
)

d.add(
d.text(
f"Over {str(special_distance1)} km" ,
insert=(70, self.height - 14.5),
fill=text_color,
style=small_value_style,
)
)

d.add(
d.rect((65, self.height - 13), (2.6, 2.6), fill=self.colors["special2"])
)

d.add(
d.text(
f"Over {str(special_distance2)} km" ,
insert=(70, self.height - 10.5),
fill=text_color,
style=small_value_style,
)
)

d.add(
d.text(
self.trans("STATISTICS"),
Expand Down Expand Up @@ -261,4 +301,4 @@ def __compute_years(self, tracks):
return
self.years = YearRange()
for t in tracks:
self.years.add(t.start_time_local)
self.years.add(t.start_time_local)

0 comments on commit 2b8079b

Please sign in to comment.