Skip to content

Commit 982f5d0

Browse files
update algorithm description
1 parent 0e33dc9 commit 982f5d0

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

algorithm.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
Everything is based on a `Grid` that contains all the data for the document. This `Grid` can be masked to show something else instead of the original, and restored to the original.
44

5-
The algorithm first starts by finding all the "large component" boxes in the grid. After that, it finds all the "small component" reference designators. Then it picks out the BOM notes so component values, etc. can be drawn.
5+
The algorithm first starts by finding all the "large component" boxes in the grid. After that, it finds all the "small component" reference designators. Then it picks out the BOM notes so component values, etc. can be included.
66

77
Once it has all the components picked out, it runs around the bounding boxes of each component and collects the flags, which are characters adjacent to the component but not the usual `|` and `-` for wires (these are masked out with normal wires.)
88

9-
Next, wires are mapped out with a flood fill algorithm and drawn, one `<g>` per wire.
9+
Next, wires are mapped out with a tree-walking search algorithm, hopping between corners (which is either breadth-first or depth-first, depending on whether I left the 0 in the `frontier.pop()`) and each group of wires is drawn and placed in a `<g class="wire">`.
1010

11-
Then for each designator, the terminals are dispatched to the function to generate the SVG path of the component, returning its own `<g>` that can be styled.
11+
Then for each designator, the terminals and bounding boxes are dispatched to a function to generate the SVG path of the component, and it is wrapped in a `<g class="component">` that can be styled.
1212

13-
***--- IMPLEMENTATION LIMIT OF CURRENT CODE... more coming soon ---***
13+
All of the `<g>`'s are then concatenated together and wrapped in an enclosing `<svg>` element.
1414

15-
All of the `<g>`'s are concatenated together and wrapped in an enclosing `<svg>` element.
16-
17-
That's pretty much it.
15+
That's pretty much it. The CSS does all the rest.

schemascii/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ def iterate_line(p1: complex, p2: complex, step: float = 1.) -> GeneratorType:
7979

8080

8181
def deep_transform(data, origin: complex, theta: float):
82-
"""Transform the point first by translating by origin,
83-
then rotating by theta."""
82+
"""Transform the point or points first by translating by origin,
83+
then rotating by theta. Returns an identical data structure,
84+
but with the transformed points substituted."""
8485
if isinstance(data, list | tuple):
8586
return [deep_transform(d, origin, theta) for d in data]
8687
if isinstance(data, complex):

0 commit comments

Comments
 (0)