Files
adebaumann 3b1e244d55 Fix final-review findings: unit-label baseline, sqrt minor-tick math, dead code, edge cases
- Unit label was vertical-centered on a box derived from a baseline
  coordinate, shifting it 3.34mm too low and making the generated
  deliverables inconsistent with E440-Scale_template.svg. UNIT_Y is now
  used directly as the baseline; regenerated E440-Scale_paths.svg and
  E440-Scale_text.svg accordingly.
- sqrt scale's minor-tick angle formula double-applied the square-root
  mapping, badly misplacing minor ticks. Removed the special case so sqrt
  falls through to the already-correct generic value-interpolation branch.
  Corrected README's sqrt row (crowds toward the high end, not low).
- Removed dead code: unused _has_markup(), identity-transform wrapper and
  _UNIT_SCALE_X in _markup_unit_svg, unreachable max_val<=0 check,
  redundant math.isinf() in the minor-tick condition.
- Linear scale with min==max now raises ValueError like the other three
  mappings, instead of silently producing a degenerate dial.
- Form numeric parsing moved inside the try/except so bad input returns
  400 instead of crashing with 500.
- left_label/right_label now split on splitlines() to handle CRLF from
  browser textareas correctly.
- Formatting consistency: PIVOT_CIRCLE_R/R0 use :.5f like other constants;
  font_face indentation matches its sibling elements.
- LICENSE and CLAUDE.md: last M1730-Scale references and a doc inaccuracy
  about which labels are live text vs. outlined paths.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-29 00:48:54 +02:00

62 lines
4.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
SVG scale artwork for E440-style round-dial analog meters. The scales are designed in Inkscape (v1.4.3) using **Alte DIN 1451 Mittelschrift**, a German technical drafting standard typeface.
The canvas is **93.824249 mm × 57.215687 mm**. The coordinate origin is offset: `transform="translate(-60.717741,-107.14126)"` is applied to `layer1` in all files, so absolute SVG coordinates start around x=61, y=107 rather than 0,0.
## File Roles
The three SVG files represent layers of the same design, intended to be combined or used separately:
- **`E440-Scale_template.svg`** — Inkscape working template. Contains the case body path (with mounting ears and rim cutout), the pivot guide circle, tick marks, numeric labels `0``50`, the `uA` unit label, and `Text`/`Left` and `Text`/`Right` corner label placeholders.
- **`E440-Scale_paths.svg`** — Paths-only version: all tick marks and text as `<path>`/`<line>` elements, no live text. Used for cutting/printing workflows where fonts must not be embedded as live text.
- **`E440-Scale_text.svg`** — Text-overlay version: tick mark lines plus live `<text>` elements for numeric/corner labels (the unit label is always emitted as outline paths since it supports markup), font embedded as base64.
## Key Design Parameters
- Stroke colors: `#1a1a1a` (dark near-black) for tick marks, numeric/unit/corner text; fill `#f9f9f9` for the case body; `#000000` for the rim arc stroke; `#b3b3b3` for the pivot guide circle.
- Fixed case geometry (identical across every generated scale — only tick/label/text content varies):
- Pivot point (local, pre-translate frame): `(107.42845, 162.62819)`
- Rim / inner-tick radius: `43.842751` mm
- Angular sweep: `±45.667193°` from vertical, clockwise-positive (low value on the left)
- Tick radial lengths: major `4.7839203` mm, medium `3.1215858` mm, small `1.8121802` mm
- Tick stroke widths: major `0.79658329`, medium `0.37985462`, small `0.27478597`
- Label radius: `49.862` mm
- Tick tiers: major ticks at each labeled interval boundary; a medium tick appears only when the minor-tick count per interval is odd, at the exact midpoint subdivision; all other subdivisions render as small ticks.
- Numeric labels rotate to follow the arc (radial orientation), matching their tick's angle.
## Web Generator (`web/`)
A Flask app that generates scale SVGs from a form. The venv lives at the repo root.
```
source .venv/bin/activate
cd web && python app.py # runs on http://localhost:5000
```
`app.py` has one route (`GET /`) serving the form and one (`POST /generate`) that returns SVG. All SVG geometry is computed in `generate_svg()` using the same coordinate constants as the hand-drawn files: ticks and labels are positioned "as if angle=0" (straight up from the pivot) and given an SVG `rotate(angle, PIVOT_X, PIVOT_Y)` transform. The form exposes: unit label, min/max values, scale mapping, major tick intervals, minor ticks per interval, number of numeric labels, custom labels, label size, font, output mode, and left/right corner labels (up to 2 lines each).
Fonts are loaded at startup from every `.ttf` in `fonts/` and embedded as base64 in every generated SVG (text output mode) so output files are self-contained. The default font is `alte-din-1451-mittelschrift.regular`.
## Container & Kubernetes
```
docker build -t e440-scale:latest .
```
`fonts/` must contain the required TTF files before building.
```
kubectl apply -f k8s/
```
`k8s/ingress.yaml` adds a Traefik `IngressRoute` for `works.baumann.gr/E440-generator` and a `stripPrefix` middleware. Adjust `certResolver` in the file if your Traefik instance uses a different name.
## Editing SVG files directly
Open files in **Inkscape**. There is no build, lint, or test tooling — changes are made directly to the SVG XML or via Inkscape's GUI. When modifying tick positions or labels, keep all three files consistent.