Skip to content

Commit cf102a7

Browse files
authored
🔀 Merge pull request #18 from davep/location-display
Have the position display adapt to the zoom level
2 parents 98585df + f973d9b commit cf102a7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
([#9](https://github.com/davep/complexitty/pull/9))
99
- Fixed the `--zoom` command line switch so that it accepts floating point
1010
values. ([#11](https://github.com/davep/complexitty/issues/11))
11+
- Changed the display of the X/Y location so that the precision adapts to
12+
the zoom level. ([#14](https://github.com/davep/complexitty/issues/14))
1113

1214
## v0.2.0
1315

src/complexitty/screens/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
##############################################################################
44
# Python imports.
55
from argparse import Namespace
6+
from math import floor, log10
67
from re import Pattern, compile
78
from typing import Final
89

@@ -145,8 +146,18 @@ def _update_situation(self, message: Mandelbrot.Plotted) -> None:
145146
Args:
146147
message: The message letting us know the plot finished.
147148
"""
149+
x_precision = (
150+
-floor(log10(abs(message.mandelbrot.x_pixel_size)))
151+
if message.mandelbrot.x_pixel_size
152+
else 0
153+
)
154+
y_precision = (
155+
-floor(log10(abs(message.mandelbrot.y_pixel_size)))
156+
if message.mandelbrot.y_pixel_size
157+
else 0
158+
)
148159
message.mandelbrot.border_title = (
149-
f"X: {message.mandelbrot.x_position:.10f} | Y: {message.mandelbrot.y_position:.10f} "
160+
f"X: {message.mandelbrot.x_position:.{x_precision + 2}f} | Y: {message.mandelbrot.y_position:.{y_precision + 2}f} "
150161
f"| Zoom: {message.mandelbrot.zoom:.4f}"
151162
)
152163
message.mandelbrot.border_subtitle = (

0 commit comments

Comments
 (0)