← Commit history
Publish 0.1.3
4 files changed
+60−6
package.json+1−1@@ -2,7 +2,7 @@ "name": "component-hero", "slug": "component-hero", "title": "Component Hero",- "version": "0.1.2",+ "version": "0.1.3", "type": "skill", "description": "The Adom standard (adom-hero 1.0) for a component page's annotated 3D hero, and a deterministic generator for it.", "brief": "The Adom standard for a component page's 3D hero: teal dashed pad outlines, silkscreen with pin 1, signal names. Spec + deterministic generator.",
page.json+21−2@@ -4,7 +4,7 @@ "type": "skill", "title": "Component Hero", "brief": "The Adom standard for a component page's 3D hero: teal dashed pad outlines, silkscreen with pin 1, signal names. Spec + deterministic generator.",- "version": "0.1.2",+ "version": "0.1.3", "hero": { "type": "image", "path": "screenshots/hero.png"@@ -53,5 +53,24 @@ "source_path": "SKILL.md", "sub_skills": [], "parent_app": null,- "org": "adom"+ "org": "adom",+ "name": "component-hero",+ "description": "The Adom standard (adom-hero 1.0) for a component page's annotated 3D hero, and a deterministic generator for it.",+ "files": [+ "package.json",+ "SKILL.md",+ "README.md",+ "install.sh",+ "uninstall.sh",+ "scripts/install.py",+ "scripts/uninstall.py",+ "skills/**",+ "docs/hero.png",+ "screenshots/showcase.png"+ ],+ "dependencies": {},+ "scripts": {+ "install": "./install.sh",+ "uninstall": "./uninstall.sh"+ } }
skills/component-hero/SKILL.md+3@@ -58,5 +58,8 @@ OK stm32g071c8t6-hero.glb: pads 48, silk items 9, pin1 footprint silkscreen, lab - **Pin names:** use the datasheet spelling from the page's pinout. Never use project net names. Pad numbers are the fallback when a pin has no real name. - **No labels** on exposed pads or ball grids. The generator records why in the metadata.+- **Single-row parts** (1xN headers, SIP, TO-92, TO-220): three or more pads whose copper lines up in one column+ label on the right, in one row label below, all on one line, never between two pads (adom/component-hero#2).+- Silkscreen strokes are obstacles, one per segment: a label steps past an outline line instead of sitting on it. - **Pin 1:** the footprint's own pin-1 mark counts. An added dot is recorded as AI-added. - **Clean downloads:** the artwork never goes into the board-use model.
skills/component-hero/scripts/hero_glb.py+35−3@@ -328,12 +328,22 @@ def label_plan(pads, names, obstacles=()): cx, cy = (min(xs) + max(xs)) / 2, (min(ys) + max(ys)) / 2 hx, hy = (max(xs) - min(xs)) / 2 or 1e-6, (max(ys) - min(ys)) / 2 or 1e-6 plan, seen = [], set()+ # one column or one row of 3+ pads (1xN header, SIP, TO-92; Noah, adom/component-hero#2): the extent across the+ # row is 0, so the extreme-based split below put interior labels in the gaps between pads. All on one side.+ # The copper must line up too, not only the centres: SOT-89's pad 2 is a custom pad centred in the row whose+ # copper runs out over the tab, and the extreme-based split already labels that one well.+ ed = [pad_outline(p) for p in sig]+ lines_up = lambda k: all(max(f(v[k] for v in o) for o in ed) - min(f(v[k] for v in o) for o in ed) < 0.3 for f in (min, max))+ one_col = len(sig) > 2 and max(xs) - min(xs) < 0.3 and lines_up(0)+ one_row = len(sig) > 2 and not one_col and max(ys) - min(ys) < 0.3 and lines_up(1) for p in sig: if p['number'] in seen: continue # multi-pad numbers (split EP, shield legs) labelled once seen.add(p['number']) # side = the extreme it sits closest to (normalised), so a 2-row part splits left/right or top/bottom dxn, dyn = (p['x'] - cx) / hx, (p['y'] - cy) / hy- if len(sig) == 2 or abs(dxn) >= abs(dyn): side = 'R' if p['x'] >= cx else 'L'+ if one_col: side = 'R'+ elif one_row: side = 'B'+ elif len(sig) == 2 or abs(dxn) >= abs(dyn): side = 'R' if p['x'] >= cx else 'L' else: side = 'B' if p['y'] >= cy else 'T' same = [q for q in sig if q is not p and ((side in 'LR' and abs(q['x'] - p['x']) < 0.3) or (side in 'TB' and abs(q['y'] - p['y']) < 0.3))] pitch = min([abs((q['y'] - p['y']) if side in 'LR' else (q['x'] - p['x'])) for q in same] or [99])@@ -348,16 +358,38 @@ def label_plan(pads, names, obstacles=()): if side == 'T': plan.append(dict(pad=p['number'], text=text, x=p['x'], y=min(ey) - gap, align='left', vertical=True, h=h)) if side == 'B': plan.append(dict(pad=p['number'], text=text, x=p['x'], y=max(ey) + gap, align='right', vertical=True, h=h)) lb = plan[-1]- for _ in range(4): # step outward past a silkscreen shape (the footprint's pin-1 triangle, our dot)+ for _ in range(8): # step outward past a silkscreen shape (pin-1 triangle, our dot, an outline stroke) hit = next((ob for ob in obstacles if overlaps(label_box(lb), ob)), None) if not hit: break if side == 'L': lb['x'] = hit[0] - gap if side == 'R': lb['x'] = hit[1] + gap if side == 'T': lb['y'] = hit[2] - gap if side == 'B': lb['y'] = hit[3] + gap+ if plan and one_col: # one line: every label starts where the furthest-pushed one does+ mx = max(lb['x'] for lb in plan)+ for lb in plan: lb['x'] = mx+ if plan and one_row:+ my = max(lb['y'] for lb in plan)+ for lb in plan: lb['y'] = my return plan, None +def silk_obstacles(silk):+ """Boxes a label must not sit on: each filled shape whole, and each stroke SEGMENT widened by half its line+ width. Per segment, not per polyline: the bounding box of a closed outline covers everything inside it, which+ would push every label out of a connector's or module's outline."""+ out = []+ for kind, pts, w in silk:+ if not pts: continue+ if kind == 'fill':+ out.append((min(q[0] for q in pts), max(q[0] for q in pts), min(q[1] for q in pts), max(q[1] for q in pts)))+ continue+ r = (w or 0) / 2+ for a, b in zip(pts, pts[1:]):+ out.append((min(a[0], b[0]) - r, max(a[0], b[0]) + r, min(a[1], b[1]) - r, max(a[1], b[1]) + r))+ return out++ def thermal_like(p, pads): """Exposed/thermal pad: named EP/PAD, or a pad much larger than the median sitting inside the others.""" if re.match(r'^(EP|PAD|TAB|0)$', p['number'], re.I): return True@@ -530,7 +562,7 @@ def build(src_glb, kmod, page_json, out, mpn=None, png=None): x, y, r, _ = dot ring = [(x + r * math.cos(t), y + r * math.sin(t)) for t in np.linspace(0, 2 * math.pi, 33)[:-1]] silk_tris += fill_tris([ring])- obstacles = [(min(q[0] for q in pts), max(q[0] for q in pts), min(q[1] for q in pts), max(q[1] for q in pts)) for kind, pts, _ in silk if kind == 'fill']+ obstacles = silk_obstacles(silk) if dot and not existing_mark: obstacles.append((dot[0] - dot[2], dot[0] + dot[2], dot[1] - dot[2], dot[1] + dot[2])) plan, why_no_labels = label_plan(pads, names, obstacles) name_up, name_down = [], []