Skip to content

Commit

Permalink
0.6.7 - Fix aspect ratio detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed May 6, 2024
1 parent 64f1464 commit 0701505
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 0
minor: 6
patch: 6
patch: 7
entry: svgen
22 changes: 14 additions & 8 deletions svgen/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ def common_sizes(

# Look for a ratio equivalent to a known one and iterate over sizes.
for common, sizes in COMMON_SIZES.items():
candidate = AspectRatio.create(common)
if candidate == ratio:
yield from sizes

# Check if this is a rotated version of this common ratio.
elif candidate.rotate() == ratio:
for size in sizes:
yield size.rotate()
candidates = [AspectRatio.create(common)] + sizes

# Attempt to match to a common aspect ratio.
for candidate in candidates:
found = False
if candidate == ratio:
yield from sizes
found = True
break

# Check if this is a rotated version of this common ratio.
if not found and candidate.rotate() == ratio:
for size in sizes:
yield size.rotate()
2 changes: 2 additions & 0 deletions tests/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ def test_aspect_ratio_basic():
assert list(common_sizes("5:4"))
assert list(common_sizes("4:5"))
assert list(common_sizes(ViewBox(0, 0, 800, 600)))

assert list(common_sizes(ViewBox(0, 0, 3440, 1440)))

0 comments on commit 0701505

Please sign in to comment.