Fix sqrt minor ticks: crowd toward low end via squared position
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: m1730-generator
|
- name: m1730-generator
|
||||||
image: git.baumann.gr/adebaumann/m1730-generator:0.78
|
image: git.baumann.gr/adebaumann/m1730-generator:0.79
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
|
|||||||
+12
-3
@@ -8,7 +8,7 @@ from fontTools.pens.svgPathPen import SVGPathPen
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
VERSION = "0.78"
|
VERSION = "0.79"
|
||||||
|
|
||||||
_LOGO_PATH = pathlib.Path(__file__).parent / 'static' / 'logo.png'
|
_LOGO_PATH = pathlib.Path(__file__).parent / 'static' / 'logo.png'
|
||||||
_LOGO_B64 = base64.b64encode(_LOGO_PATH.read_bytes()).decode()
|
_LOGO_B64 = base64.b64encode(_LOGO_PATH.read_bytes()).decode()
|
||||||
@@ -444,12 +444,21 @@ def generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks, la
|
|||||||
f' style="stroke:#1a1a1a;stroke-width:0.555;stroke-linecap:butt" />'
|
f' style="stroke:#1a1a1a;stroke-width:0.555;stroke-linecap:butt" />'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Minor ticks — evenly spaced in value, then positioned by the scale mapping.
|
# Minor ticks — placement depends on scale type:
|
||||||
# On a linear scale this is uniform; on a log scale they crowd toward the high end.
|
# linear: uniform physical spacing (= uniform value spacing)
|
||||||
|
# log: linear value interpolation between geometric major values
|
||||||
|
# (crowds toward high end of each interval)
|
||||||
|
# sqrt: sqrt of fractional position within each interval, giving
|
||||||
|
# consistent high-end crowding across all intervals; using
|
||||||
|
# value interpolation instead would concentrate the crowding
|
||||||
|
# only near zero (where sqrt is steepest) and look linear elsewhere.
|
||||||
if small_ticks > 0:
|
if small_ticks > 0:
|
||||||
sub = small_ticks + 1
|
sub = small_ticks + 1
|
||||||
for i in range(big_ticks):
|
for i in range(big_ticks):
|
||||||
for j in range(1, small_ticks + 1):
|
for j in range(1, small_ticks + 1):
|
||||||
|
if scale_type == 'sqrt':
|
||||||
|
x = big_xs[i] + (j / sub) ** 2 * (big_xs[i + 1] - big_xs[i])
|
||||||
|
else:
|
||||||
v = big_vals[i] + j * (big_vals[i + 1] - big_vals[i]) / sub
|
v = big_vals[i] + j * (big_vals[i + 1] - big_vals[i]) / sub
|
||||||
x = value_to_x(v)
|
x = value_to_x(v)
|
||||||
parts.append(
|
parts.append(
|
||||||
|
|||||||
Reference in New Issue
Block a user