[AC] [DA] and [ACDC] added

This commit is contained in:
2026-07-30 13:17:41 +02:00
parent cef3063b3d
commit cfe4b48856
14 changed files with 69 additions and 1 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -15,7 +15,7 @@ spec:
spec: spec:
containers: containers:
- name: e440-generator - name: e440-generator
image: git.baumann.gr/adebaumann/e440-generator:1.01 image: git.baumann.gr/adebaumann/e440-generator:1.02
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 5000 - containerPort: 5000
+68
View File
@@ -101,6 +101,57 @@ _FRAC_AXIS = 0.32
_FRAC_GAP = 0.14 _FRAC_GAP = 0.14
_FRAC_SIDE = 0.12 _FRAC_SIDE = 0.12
_SYM_WIDTH = 0.75
_SYM_HEIGHT = 0.50
_SYM_LW = 0.08
_SYM_RISE = 0.25
def _symbol_svg(name: str, x: float, y: float, fs: float, fill: str) -> str:
w = fs * _SYM_WIDTH
h = fs * _SYM_HEIGHT
lw = fs * _SYM_LW
yc = y - _SYM_RISE * fs
stroke = f"fill:none;stroke:{fill};stroke-width:{lw:.5f};stroke-linecap:round"
if name == "ac":
d = (
f"M {x:.5f},{yc:.5f}"
f" C {x + w / 3:.5f},{yc - h / 2:.5f}"
f" {x + 2 * w / 3:.5f},{yc + h / 2:.5f}"
f" {x + w:.5f},{yc:.5f}"
)
return f'<path style="{stroke}" d="{d}"/>'
elif name == "dc":
dash = w / 5
gap = w / 5
y1 = yc - h / 4
y2 = yc + h / 4
p1 = f'<line x1="{x:.5f}" y1="{y1:.5f}" x2="{x + w:.5f}" y2="{y1:.5f}" style="{stroke}" />'
p2 = f'<line x1="{x:.5f}" y1="{y2:.5f}" x2="{x + dash:.5f}" y2="{y2:.5f}" style="{stroke}" />'
p3 = f'<line x1="{x + dash + gap:.5f}" y1="{y2:.5f}" x2="{x + 2 * dash + gap:.5f}" y2="{y2:.5f}" style="{stroke}" />'
p4 = f'<line x1="{x + 2 * dash + 2 * gap:.5f}" y1="{y2:.5f}" x2="{x + w:.5f}" y2="{y2:.5f}" style="{stroke}" />'
return p1 + "\n " + p2 + "\n " + p3 + "\n " + p4
else: # acdc
y_wave = yc - h / 4
y_dash = yc + h / 4
dash = w / 5
gap = w / 5
d = (
f"M {x:.5f},{y_wave:.5f}"
f" C {x + w / 3:.5f},{y_wave - h / 2:.5f}"
f" {x + 2 * w / 3:.5f},{y_wave + h / 2:.5f}"
f" {x + w:.5f},{y_wave:.5f}"
)
p1 = f'<path style="{stroke}" d="{d}"/>'
p2 = f'<line x1="{x:.5f}" y1="{y_dash:.5f}" x2="{x + dash:.5f}" y2="{y_dash:.5f}" style="{stroke}" />'
p3 = f'<line x1="{x + dash + gap:.5f}" y1="{y_dash:.5f}" x2="{x + 2 * dash + gap:.5f}" y2="{y_dash:.5f}" style="{stroke}" />'
p4 = f'<line x1="{x + 2 * dash + 2 * gap:.5f}" y1="{y_dash:.5f}" x2="{x + w:.5f}" y2="{y_dash:.5f}" style="{stroke}" />'
return p1 + "\n " + p2 + "\n " + p3 + "\n " + p4
_UNIT_BOX_X0, _UNIT_BOX_X1 = UNIT_X - 15.0, UNIT_X + 15.0 _UNIT_BOX_X0, _UNIT_BOX_X1 = UNIT_X - 15.0, UNIT_X + 15.0
_UNIT_BOX_Y0, _UNIT_BOX_Y1 = UNIT_Y - 6.0, UNIT_Y + 6.0 _UNIT_BOX_Y0, _UNIT_BOX_Y1 = UNIT_Y - 6.0, UNIT_Y + 6.0
_UNIT_MAX_FS = 9.46938021 _UNIT_MAX_FS = 9.46938021
@@ -182,6 +233,16 @@ def _parse_markup(s: str):
inner, j = _extract_braced(s, i) inner, j = _extract_braced(s, i)
nodes.append(_parse_braced(inner)) nodes.append(_parse_braced(inner))
i = j i = j
elif c == "[":
end = s.find("]", i + 1)
if end > i:
name = s[i + 1 : end].lower()
if name in ("ac", "dc", "acdc"):
nodes.append(("sym", name))
i = end + 1
continue
nodes.append(("lit", c))
i += 1
else: else:
nodes.append(("lit", c)) nodes.append(("lit", c))
i += 1 i += 1
@@ -205,6 +266,8 @@ def _measure(nodes, fs: float, fd: _FontData) -> float:
max(_measure(n[1], fs2, fd), _measure(n[2], fs2, fd)) max(_measure(n[1], fs2, fd), _measure(n[2], fs2, fd))
+ 2 * _FRAC_SIDE * fs2 + 2 * _FRAC_SIDE * fs2
) )
elif n[0] == "sym":
w += fs * _SYM_WIDTH
return w return w
@@ -238,6 +301,8 @@ def _vbounds(nodes, fs: float, fd: _FontData):
dt, db = _vbounds(n[2], fs2, fd) dt, db = _vbounds(n[2], fs2, fd)
a = min(nt + num_base, axis) a = min(nt + num_base, axis)
b = max(db + den_base, axis) b = max(db + den_base, axis)
elif n[0] == "sym":
a, b = -_SYM_HEIGHT / 2 * fs, _SYM_HEIGHT / 2 * fs
else: else:
continue continue
lo, hi = min(lo, a), max(hi, b) lo, hi = min(lo, a), max(hi, b)
@@ -279,6 +344,9 @@ def _draw_nodes(nodes, x: float, y: float, fs: float, fill: str, fd: _FontData):
f' style="stroke:{fill};stroke-width:{fs * 0.055:.5f};stroke-linecap:butt" />' f' style="stroke:{fill};stroke-width:{fs * 0.055:.5f};stroke-linecap:butt" />'
) )
cx += bar_w cx += bar_w
elif n[0] == "sym":
parts.append(_symbol_svg(n[1], cx, y, fs, fill))
cx += fs * _SYM_WIDTH
return parts, cx - x return parts, cx - x