predictygraph 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {predictygraph-0.3.2 → predictygraph-0.3.3}/PKG-INFO +1 -1
- {predictygraph-0.3.2 → predictygraph-0.3.3}/pyproject.toml +1 -1
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/scene.py +26 -1
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/sketch.py +7 -4
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_sketch.py +22 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/LICENSE +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/NOTICE +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/README.md +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/__init__.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/__main__.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/anim.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/cli.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/default.css +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/Carlito-Bold.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/Carlito-Regular.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/DejaVuSans-Bold.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/DejaVuSans.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationMono-Bold.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationMono-Regular.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationSans-Bold.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationSans-Regular.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationSerif-Bold.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationSerif-Regular.ttf +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/licenses/Bitstream-Vera.txt +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/licenses/OFL-1.1.txt +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/licenses/README.md +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/ir.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/layout.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/model.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/parser.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/render/__init__.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/render/apng.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/render/svg.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/route.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/safe.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/style.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/styleutil.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/text.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/theme.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/catppuccin-frappe.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/catppuccin-latte.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/catppuccin-macchiato.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/catppuccin-mocha.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/default.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/dracula.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/github-light.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/gruvbox-dark.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/hami.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/nord.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/solarized-dark.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/solarized-light.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/trunkline.toml +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_annotations.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_blocks.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_diagonal.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_fixes.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_hardening.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_predictygraph.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_routing.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_scene.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_stack.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_targets.py +0 -0
- {predictygraph-0.3.2 → predictygraph-0.3.3}/tests/test_trunkline.py +0 -0
|
@@ -24,6 +24,7 @@ from .route import Diagonal, Router, flow_dir, lca
|
|
|
24
24
|
from .sketch import hatch, sketchify
|
|
25
25
|
from .style import box4, px
|
|
26
26
|
from .styleutil import LINE_H, accent, font_size, has_title_band, node_padding, text_block, title_position
|
|
27
|
+
from .text import load_image
|
|
27
28
|
|
|
28
29
|
TITLE_PAD = 6.0
|
|
29
30
|
ER_HEADS = ("one", "many", "zero-one", "zero-many", "one-many")
|
|
@@ -639,8 +640,10 @@ class SceneBuilder:
|
|
|
639
640
|
if e.label:
|
|
640
641
|
lab = self.edge_label(e, self.edge_polys[e.id])
|
|
641
642
|
out.children += lab
|
|
643
|
+
if e.attrs.get("image"):
|
|
644
|
+
out.children.append(self.edge_image(e, self.edge_polys[e.id]))
|
|
642
645
|
if e.attrs.get("step"):
|
|
643
|
-
box = lab[0].geom if e.label else None
|
|
646
|
+
box = lab[0].geom if e.label and lab[0].cls == "pdg-label-bg" else None
|
|
644
647
|
out.children += self.step_badge(e, self.edge_polys[e.id], box)
|
|
645
648
|
return out
|
|
646
649
|
|
|
@@ -772,6 +775,21 @@ class SceneBuilder:
|
|
|
772
775
|
tag, pts, paint = shapes.get(kind, ("polygon", [P(0, 0), P(hl, hw), P(hl, -hw)], {"fill": color}))
|
|
773
776
|
return Elem(tag, cls="pdg-head", geom={"points": pts}, paint=paint)
|
|
774
777
|
|
|
778
|
+
def edge_image(self, e, poly) -> Elem:
|
|
779
|
+
"""`image=logo.png` on an edge: beside the middle of its longest run (right of a
|
|
780
|
+
vertical run, below a horizontal one), like a badge on a draw.io connector."""
|
|
781
|
+
img = load_image(e.attrs["image"], self.doc.base_dir, self.doc.allow_outside)
|
|
782
|
+
w = px(e.attrs.get("img-width"), 0) or min(img["w"], 48.0)
|
|
783
|
+
h = px(e.attrs.get("img-height"), 0) or w * img["h"] / (img["w"] or 1)
|
|
784
|
+
(ax, ay), (bx, by) = max(zip(poly, poly[1:]), key=lambda s: math.dist(*s))
|
|
785
|
+
mx, my = (ax + bx) / 2, (ay + by) / 2
|
|
786
|
+
gap = 8.0
|
|
787
|
+
if abs(bx - ax) < abs(by - ay):
|
|
788
|
+
x, y = mx + gap, my - h / 2
|
|
789
|
+
else:
|
|
790
|
+
x, y = mx - w / 2, my + gap
|
|
791
|
+
return Elem("image", cls="pdg-edge-image", geom={"x": x, "y": y, "w": w, "h": h, "href": img["href"]})
|
|
792
|
+
|
|
775
793
|
def edge_label(self, e, poly) -> list[Elem]:
|
|
776
794
|
st = e.label_style or e.style
|
|
777
795
|
fs = font_size(st, 11)
|
|
@@ -781,6 +799,13 @@ class SceneBuilder:
|
|
|
781
799
|
segs = list(zip(poly, poly[1:]))
|
|
782
800
|
fits = len(segs) > 1 and math.dist(*segs[-1]) >= h + 4
|
|
783
801
|
best = segs[-1] if fits else max(segs, key=lambda s: math.dist(*s))
|
|
802
|
+
at = e.attrs.get("label-at", "")
|
|
803
|
+
if at in ("start", "end") and len(segs) > 1: # sit above that run, clear of the line
|
|
804
|
+
(ax, ay), (bx, by) = segs[0] if at == "start" else segs[-1]
|
|
805
|
+
if abs(by - ay) < 0.5:
|
|
806
|
+
mx = max((ax + bx) / 2, min(ax, bx) + w / 2 + 4) # never back over the source
|
|
807
|
+
return self.text(lines, mx, ay - h - 6, fs, st)
|
|
808
|
+
best = segs[0] if at == "start" else segs[-1]
|
|
784
809
|
(ax, ay), (bx, by) = best
|
|
785
810
|
t = 0.5
|
|
786
811
|
lvl = (
|
|
@@ -50,12 +50,15 @@ def flatten(segs) -> list[list[Pt]]:
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def _simplify(poly: list[Pt]) -> list[Pt]:
|
|
53
|
-
"""Merge nearly
|
|
53
|
+
"""Merge nearly straight points so a sampled curve wobbles as a few strokes, not many.
|
|
54
|
+
A point is kept once the path turns more than ~15° there, so corners survive."""
|
|
54
55
|
out = [poly[0]]
|
|
55
56
|
for i in range(1, len(poly) - 1):
|
|
56
57
|
a, b, c = out[-1], poly[i], poly[i + 1]
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
h1 = math.atan2(b[1] - a[1], b[0] - a[0])
|
|
59
|
+
h2 = math.atan2(c[1] - b[1], c[0] - b[0])
|
|
60
|
+
turn = abs((h2 - h1 + math.pi) % (2 * math.pi) - math.pi)
|
|
61
|
+
if turn > 0.26 or math.dist(a, b) > 160:
|
|
59
62
|
out.append(b)
|
|
60
63
|
out.append(poly[-1])
|
|
61
64
|
return out
|
|
@@ -73,7 +76,7 @@ def rough_segs(polys: list[list[Pt]], rng: random.Random, roughness: float) -> l
|
|
|
73
76
|
L = math.dist(a, b)
|
|
74
77
|
if L < 0.5:
|
|
75
78
|
continue
|
|
76
|
-
r = roughness * (1 + min(L,
|
|
79
|
+
r = roughness * (1 + min(L, 300) / 150) # long strokes bow a little more, like rough.js
|
|
77
80
|
nx, ny = (a[1] - b[1]) / L, (b[0] - a[0]) / L # unit normal
|
|
78
81
|
c1, c2 = rng.uniform(-r, r), rng.uniform(-r, r)
|
|
79
82
|
p1 = (a[0] + (b[0] - a[0]) * 0.35 + nx * c1, a[1] + (b[1] - a[1]) * 0.35 + ny * c1)
|
|
@@ -61,3 +61,25 @@ def test_unknown_lucide_icon_is_an_error():
|
|
|
61
61
|
def test_def_class_from_variable():
|
|
62
62
|
svg = render('css { .w { fill: #abcdef; } }\ndef g c=x {\n t "" .$c\n}\nuse g k c=w')
|
|
63
63
|
assert 'class="pdg-node w"' in svg
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_edge_image(tmp_path):
|
|
67
|
+
from PIL import Image
|
|
68
|
+
|
|
69
|
+
Image.new("RGBA", (10, 10), "green").save(tmp_path / "logo.png")
|
|
70
|
+
(tmp_path / "d.pdg").write_text("a -> b image=logo.png img-width=20")
|
|
71
|
+
svg = render((tmp_path / "d.pdg").read_text(), base_dir=str(tmp_path))
|
|
72
|
+
edge = svg.split('<g id="e0"', 1)[1].split("</g>", 1)[0]
|
|
73
|
+
assert 'class="pdg-edge-image"' in edge and 'width="20"' in edge
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_sketch_keeps_corners():
|
|
77
|
+
svg = render("graph route=ortho\na\nb at=0,0\na -> b exit=right enter=top sketch=1 roughness=0.01")
|
|
78
|
+
edge = svg.split('<g id="e0"', 1)[1].split("</g>", 1)[0]
|
|
79
|
+
assert edge.count(" C ") >= 4 # two passes x at least two runs
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_label_at_start_has_no_background():
|
|
83
|
+
svg = render('graph route=ortho\na\nb\na -> b "x" exit=right enter=top label-at=start')
|
|
84
|
+
edge = svg.split('<g id="e0"', 1)[1].split("</g>", 1)[0]
|
|
85
|
+
assert "pdg-label-bg" not in edge and ">x<" in edge
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationMono-Regular.ttf
RENAMED
|
File without changes
|
|
File without changes
|
{predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationSans-Regular.ttf
RENAMED
|
File without changes
|
{predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationSerif-Bold.ttf
RENAMED
|
File without changes
|
{predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/LiberationSerif-Regular.ttf
RENAMED
|
File without changes
|
{predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/fonts/licenses/Bitstream-Vera.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{predictygraph-0.3.2 → predictygraph-0.3.3}/src/predictygraph/themes/catppuccin-macchiato.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|