File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 8
8
([ #9 ] ( https://github.com/davep/complexitty/pull/9 ) )
9
9
- Fixed the ` --zoom ` command line switch so that it accepts floating point
10
10
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 ) )
11
13
12
14
## v0.2.0
13
15
Original file line number Diff line number Diff line change 3
3
##############################################################################
4
4
# Python imports.
5
5
from argparse import Namespace
6
+ from math import floor , log10
6
7
from re import Pattern , compile
7
8
from typing import Final
8
9
@@ -145,8 +146,18 @@ def _update_situation(self, message: Mandelbrot.Plotted) -> None:
145
146
Args:
146
147
message: The message letting us know the plot finished.
147
148
"""
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
+ )
148
159
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 } "
150
161
f"| Zoom: { message .mandelbrot .zoom :.4f} "
151
162
)
152
163
message .mandelbrot .border_subtitle = (
You can’t perform that action at this time.
0 commit comments