Half-height unit uses lower half of panel box; bump to 0.87
Changed from top half (y0=92.8, y1=103.8) to bottom half (y0=103.8, y1=114.8). The label baseline sits at y≈101.5mm, so the lower half starts 2.3mm below it — clean visual separation without the unit appearing high up on the panel.
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.86
|
image: git.baumann.gr/adebaumann/m1730-generator:0.87
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
|
|||||||
+7
-6
@@ -9,7 +9,7 @@ from fontTools.pens.svgPathPen import SVGPathPen
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
VERSION = "0.86"
|
VERSION = "0.87"
|
||||||
|
|
||||||
_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()
|
||||||
@@ -74,7 +74,7 @@ _FRAC_SIDE = 0.12
|
|||||||
|
|
||||||
_UNIT_BOX_X0, _UNIT_BOX_X1 = 39.6, 57.4
|
_UNIT_BOX_X0, _UNIT_BOX_X1 = 39.6, 57.4
|
||||||
_UNIT_BOX_Y0, _UNIT_BOX_Y1 = 92.8, 114.8
|
_UNIT_BOX_Y0, _UNIT_BOX_Y1 = 92.8, 114.8
|
||||||
_UNIT_BOX_HALF_Y1 = (_UNIT_BOX_Y0 + _UNIT_BOX_Y1) / 2 # 103.8 — upper half of panel
|
_UNIT_BOX_HALF_Y0 = (_UNIT_BOX_Y0 + _UNIT_BOX_Y1) / 2 # 103.8 — bottom half starts here
|
||||||
|
|
||||||
|
|
||||||
def _glyph_svg(ch: str, x: float, y: float, fs: float, fill: str, fd: _FontData):
|
def _glyph_svg(ch: str, x: float, y: float, fs: float, fill: str, fd: _FontData):
|
||||||
@@ -245,10 +245,11 @@ def _has_markup(s: str) -> bool:
|
|||||||
return any(c in s for c in '^_') or ('{' in s and '}' in s)
|
return any(c in s for c in '^_') or ('{' in s and '}' in s)
|
||||||
|
|
||||||
|
|
||||||
def _markup_unit_svg(unit: str, fd: _FontData, fill='#1a1a1a', box_y1=None) -> str:
|
def _markup_unit_svg(unit: str, fd: _FontData, fill='#1a1a1a', box_y0=None, box_y1=None) -> str:
|
||||||
nodes = _parse_markup(unit)
|
nodes = _parse_markup(unit)
|
||||||
x0, x1 = _UNIT_BOX_X0, _UNIT_BOX_X1
|
x0, x1 = _UNIT_BOX_X0, _UNIT_BOX_X1
|
||||||
y0, y1 = _UNIT_BOX_Y0, (box_y1 if box_y1 is not None else _UNIT_BOX_Y1)
|
y0 = box_y0 if box_y0 is not None else _UNIT_BOX_Y0
|
||||||
|
y1 = box_y1 if box_y1 is not None else _UNIT_BOX_Y1
|
||||||
xc, yc = (x0 + x1) / 2, (y0 + y1) / 2
|
xc, yc = (x0 + x1) / 2, (y0 + y1) / 2
|
||||||
|
|
||||||
w1 = _measure(nodes, 1.0, fd)
|
w1 = _measure(nodes, 1.0, fd)
|
||||||
@@ -320,7 +321,7 @@ def generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks, la
|
|||||||
use_paths=True, scale_type='linear', custom_labels=None, label_size=9,
|
use_paths=True, scale_type='linear', custom_labels=None, label_size=9,
|
||||||
font_key=None, half_height_unit=False):
|
font_key=None, half_height_unit=False):
|
||||||
fd = _FONTS.get(font_key) or _FONTS.get(_DEFAULT_FONT) or next(iter(_FONTS.values()))
|
fd = _FONTS.get(font_key) or _FONTS.get(_DEFAULT_FONT) or next(iter(_FONTS.values()))
|
||||||
unit_box_y1 = _UNIT_BOX_HALF_Y1 if half_height_unit else None
|
unit_box_y0 = _UNIT_BOX_HALF_Y0 if half_height_unit else None
|
||||||
|
|
||||||
if scale_type == 'log':
|
if scale_type == 'log':
|
||||||
if min_val <= 0 or max_val <= 0:
|
if min_val <= 0 or max_val <= 0:
|
||||||
@@ -432,7 +433,7 @@ def generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks, la
|
|||||||
# correct sizing for all fonts. Text mode for plain normal-height units
|
# correct sizing for all fonts. Text mode for plain normal-height units
|
||||||
# keeps live <text> nodes; half-height always uses paths for correct centering.
|
# keeps live <text> nodes; half-height always uses paths for correct centering.
|
||||||
if use_paths or _has_markup(unit) or half_height_unit:
|
if use_paths or _has_markup(unit) or half_height_unit:
|
||||||
unit_svg = ' ' + _markup_unit_svg(unit, fd, box_y1=unit_box_y1)
|
unit_svg = ' ' + _markup_unit_svg(unit, fd, box_y0=unit_box_y0)
|
||||||
else:
|
else:
|
||||||
fs = _unit_font_size(unit, fd)
|
fs = _unit_font_size(unit, fd)
|
||||||
unit_svg = (
|
unit_svg = (
|
||||||
|
|||||||
Reference in New Issue
Block a user