Skip to content

Commit

Permalink
Merge branch 'feat-reduce-grid-svg-size'
Browse files Browse the repository at this point in the history
* feat-reduce-grid-svg-size:
  feat: reduce grid svg file size
  fix: show in firefox
  doc: runner info fix

# Conflicts:
#	README-CN.md
#	README.md
  • Loading branch information
ben-29 committed Oct 28, 2023
2 parents c172610 + d9e081a commit 60b4375
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions run_page/gpxtrackposter/github_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
f"{year}",
insert=offset.tuple(),
fill=self.poster.colors["text"],
alignment_baseline="hanging",
dominant_baseline="hanging",
style=year_style,
)
)
Expand All @@ -90,7 +90,7 @@ def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
f"{year_length} {km_or_mi}",
insert=(offset.tuple()[0] + 165, offset.tuple()[1] + 5),
fill=self.poster.colors["text"],
alignment_baseline="hanging",
dominant_baseline="hanging",
style=year_length_style,
)
)
Expand Down Expand Up @@ -137,4 +137,4 @@ def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
dr.add(rect)
github_rect_day += datetime.timedelta(1)
rect_x += 3.5
offset.y += 3.5 * 9 + year_size + 1.5
offset.y += 3.5 * 9 + year_size + 1.0
6 changes: 5 additions & 1 deletion run_page/gpxtrackposter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ def project(
scale = size.x / d_x if size.x / size.y <= d_x / d_y else size.y / d_y
offset = offset + 0.5 * (size - scale * XY(d_x, -d_y)) - scale * XY(min_x, min_y)
lines = []
# If len > $zoom_threshold, choose 1 point out of every $step to reduce size of the SVG file
zoom_threshold = 400
for latlngline in latlnglines:
line = []
for latlng in latlngline:
step = int(len(latlngline) / zoom_threshold) + 1
for i in range(0, len(latlngline), step):
latlng = latlngline[i]
if bbox.contains(latlng):
line.append((offset + scale * latlng2xy(latlng)).tuple())
else:
Expand Down

0 comments on commit 60b4375

Please sign in to comment.