Commit Graph
35 Commits
Author SHA1 Message Date
David Stadelmann a839dbb6d2 docs: document per-port shape overrides and rebuild manual
Document the per-port `shape`, `kind`, `size`, `stroke`, and `fill`
overrides in the ports dictionary of `element.elmt`, simplify the
`port-shape` parameter description, and update `port-shape-vertices`
return signature. Also reformat source and examples for consistency
and rebuild manual.pdf.
2026-09-16 10:07:13 +02:00
David Stadelmann 663614056e feat: Expose cardinal sub-anchors on pentagon-shaped ports
Wire up each port as a CeTZ group carrying, in addition to the
default attach anchor, four world-cardinal sub-anchors
`.east`, `.west`, `.north`, `.south` sitting on the pentagon's
bounding-box midpoints. This lets wires attach to any face of a
pentagon port instead of only the default outer/inner point:

  wire.wire("w", ("src", "blk-port-a.east"), ...)

Sub-anchor semantics are world-oriented (not rotated with the shape),
so the tip's cardinal name follows its actual world direction:

  - west  side, kind "in"  → tip = .east    (kind "out" → .west)
  - east  side, kind "in"  → tip = .west    (kind "out" → .east)
  - north side, kind "in"  → tip = .south   (kind "out" → .north)
  - south side, kind "in"  → tip = .north   (kind "out" → .south)

Bounding-box extents depend only on side orientation (horizontal for
east/west, vertical for north/south); `kind` mirrors the shape but
preserves the bbox, so cardinal names stay stable.

Non-pentagon ports degenerate all four sub-anchors to the default
attach point, so user code can address `.east`/`.west`/etc.
uniformly regardless of port shape. The bare port anchor name
(`<elmt-id>-port-<port-id>`) resolves to the same coordinate as
before via a custom "default" anchor, preserving backward
compatibility. Debug mode still marks only the default attach point.

Add `examples.port-shape-attach` demonstrating attaching wires to
the `.west`, `.east` and `.north` faces of a single pentagon port.
2026-09-14 18:22:31 +02:00
David Stadelmann 72eab1620c feat: Add anchor-based zigzag bend placement via zigzag-at
Introduce a new `zigzag-at` parameter on `wire.wire` as an alternative
to `zigzag-ratio` for positioning the middle bend segment of a
`style: "zigzag"` wire. Instead of a fraction of the endpoint span,
the bend is placed on the axis of a referenced anchor via CeTZ's
perpendicular operator (`|-`):

  - zigzag-dir "vertical":   segment sits at anchor.x
  - zigzag-dir "horizontal": segment sits at anchor.y

Accepted forms:
  - str                         — raw CeTZ anchor name (e.g. port anchor
                                  "elmt-port-id" or "elmt.center")
  - array / native CeTZ dict    — used as-is
  - (rel: <length>, to: <coord>) with scalar rel — ergonomic axial
    offset, rewritten to (rel: (dx, 0), to: ...) for vertical dir or
    (rel: (0, dy), to: ...) for horizontal dir

`zigzag-ratio` default flipped from `50%` to `auto` (still resolves
to 50%) to allow detecting an explicit user override. Panics on
misuse:
  - `zigzag-at` set together with an explicit `zigzag-ratio`
  - `zigzag-at` set with a non-zigzag `style`

Add `examples.zigzag-at` demonstrating both the string-anchor and the
ergonomic offset forms.
2026-09-14 17:47:09 +02:00
David Stadelmann fff5b2ecd5 feat: Support cross-element port alignment via align-with
Extend the port `align-with` field to accept references to ports of
other elements, in addition to the existing local-port form:

  - "<local-id>"                    → same-element port (unchanged)
  - (element: "<id>", port: "<id>") → cross-element reference
  - "<raw-anchor>"                  → arbitrary CeTZ anchor name

Cross-element alignment is implemented via CeTZ perpendicular
projection (`|-`) so the port sits on this element's side line while
sharing the remote port's y (east/west) or x (north/south) coordinate.
Local resolution still validates matching axis and detects cycles;
external refs skip axis validation (remote side unknown at eval time)
and require the target element to be drawn first.

Also enrich port-related panic messages with the element id and port
context to make offending figures easier to locate, and add a manual
example (`examples.align-with-ports`) demonstrating both local and
cross-element alignment.
2026-09-14 17:12:57 +02:00
David Stadelmann fd761487ff feat: Add parameter shell to block (alternative to group)
Defining a block and placing elements into that block has the benefit
that you can use the ports to align the elements within the block to the
ports of that outer ("shell") block
2026-09-14 11:45:55 +02:00
David Stadelmann b8a8d38ed2 feat: Allow port names to be placed outside of a block 2026-09-14 11:42:37 +02:00
David Stadelmann 6070ce7fe3 feat: Add wire.breakout element for bus fan-out diagrams
Introduces wire.breakout: a 45° diagonal line of configurable length
(default 1em) that starts at a given (x, y) and exposes a port anchor
<id>-port-<id> at its end point so wires can attach to it as if it were
a block port. A synthesized <id>.center anchor is placed opposite the
configured port-side so wire.wire with style "u-shape" can auto-detect
the port's cardinal side.
- x/y accept number, (rel:, to:) and (from:) forms; (from:) sets the
  start point to the referenced anchor's coordinate.
- direction: one of north-east/north-west/south-east/south-west.
- Optional label positioned via name-pos (NE/NW/SE/SW); when name-pos is
  opposite to direction, the label falls back to the start point so it
  never covers the diagonal line. Label padding matches wire.wire (3pt).
Also adds three examples (breakout, breakout-label, breakout-wire) in
doc/examples.typ referenced from the docstring so tidy auto-renders
them in the manual, and a gallery entry (gallery/test_breakout.typ)
demonstrating orthogonal bus fan-out with breakouts in all four
directions.
2026-08-26 09:45:24 +02:00
David Stadelmann a51e8bb93b feature: Add port shape 2026-08-17 15:00:02 +02:00
David Stadelmann 563bb7b1d2 feat: Add port-name-padding parameter
Replaces the hard-coded 2pt padding used when placing port name labels.
Configurable per element via port-name-padding on elmt (forwarded by
block and group), defaulting to 2pt to preserve existing layout.
2026-08-17 14:13:06 +02:00
David Stadelmann 0d1478c765 feat: Add ports on group elements
Groups now accept ports/ports-margins like blocks. Port name labels
default to outside the group border (outside-port-names: true) so they
don't overlap child elements; set to false for block-style inside
labels.
2026-08-17 14:12:50 +02:00
David Stadelmann 002db0e6f5 feat: Add u-shape wire-style 2026-08-17 11:59:21 +02:00
David Stadelmann 0fb4929aca feat: Add relative y coordinates 2026-08-17 11:17:05 +02:00
David Stadelmann 320318a25b deps: update tidy to 0.4.3 2026-07-28 14:45:49 +02:00
David Stadelmann 9bcd91131c deps: update CeTZ 0.3.4 to 0.5.2 with coordinate fixes 2026-07-28 14:43:25 +02:00
HEL 0612e9b6ec chore: bump to 0.2.1 2026-06-30 21:13:41 +02:00
HEL 091ec8c08a chore: update manual 2026-06-30 19:13:19 +02:00
Shmerlard 87643983ec added guided wire 2025-08-17 22:05:36 +03:00
bono 94d5d6b854 add examples and add iec gates to manual 2025-06-28 13:56:22 -03:00
HEL 371caf094c updated README and manual with new version 2025-03-01 22:23:52 +01:00
HEL ff0b91e683 updated compiler version + dependencies 2025-03-01 21:22:08 +01:00
HEL 9a1fda087c prepared for publication + bumped to 0.1.0 2024-10-02 21:09:48 +02:00
HEL 6a6ae96a96 changed AND design (circle arc instead of bezier) 2024-05-18 22:36:27 +02:00
HEL a856b7f634 added doc for wire.intersection 2024-05-18 21:52:46 +02:00
HEL d6248865b3 added gallery rendering script 2024-05-18 18:08:36 +02:00
HEL ff9ad9e94a changed version number 2024-05-18 17:08:08 +02:00
HEL 4dc69a92c5 updated manual 2024-05-18 17:07:14 +02:00
HEL 86d9122740 added groups 2024-05-18 13:06:57 +02:00
HEL 66ac91af7b added stub name offset parameter 2024-05-17 23:52:43 +02:00
HEL 047c3b8893 improved doc + made it fancier 2024-05-17 23:07:17 +02:00
HEL 64a6146f32 added doc for gates + minor changes 2024-05-17 22:24:38 +02:00
HEL a9014e03e9 added doc cross-reference links 2024-05-17 18:12:25 +02:00
HEL c01e33cab4 added blue color 2024-05-17 16:58:40 +02:00
HEL 4d97062d30 improved doc + moved examples to separate file 2024-05-17 16:52:43 +02:00
HEL ccc38c3e1d added doc for elements 2024-05-17 14:19:27 +02:00
HEL 7e0209b712 added doc for circuit, util and wire 2024-05-17 09:36:38 +02:00