pd-code-to-diagram
Convert PD codes to routed diagram matrices, render images, and parse supported diagram matrices back to PD codes.
Installation
pip install pd-code-to-diagram
Usage example
from pd_code_to_diagram import get_diagram_from_pd_code, diagram_to_png
pd = [[1, 5, 2, 4], [3, 1, 4, 6], [5, 3, 6, 2]]
diagram = get_diagram_from_pd_code(pd)
diagram_to_png(diagram, "trefoil.png", tile_size=40, show_socket_labels=True)
print(len(diagram), len(diagram[0]))
Algorithm
The bundled C++ engine builds a crossing/socket tree, incrementally places crossings, and routes arcs through a grid path engine while avoiding occupied cells and preserving crossing over/under data. Python converts the matrix to cached antialiased Pillow tiles or traces a supported matrix back into crossing records. Matrix values use 0 for empty cells, positive integers for arcs, and negative values for the two crossing orientations.
Input conventions
A PD code is represented as a list of four-entry crossings. Arc labels normally occur exactly twice. Public functions validate inputs and return new values rather than mutating caller-owned data unless their API explicitly says otherwise.
External software
- A C++17 compiler such as GCC or Clang is required on first use to build the bundled layout executable.
- No GUI is required.
- Writing PNG images requires normal filesystem access.
Development
Run examples and package checks before release. Python packages require Python 3.10 or newer. Build PyPI artifacts with:
poetry check
poetry build
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pd_code_to_diagram-0.1.10.tar.gz.
File metadata
- Download URL: pd_code_to_diagram-0.1.10.tar.gz
- Upload date:
- Size: 49.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1efa3387007f7238e7afebd6b1a6857603f6ddad2838e3a91524a8c9d96aaa9
|
|
| MD5 |
cbbe018b38e103627b0675a2f84af691
|
|
| BLAKE2b-256 |
e4118dd28fb04e0428ca7ab32afc9577a70911428452fe8fe7a4128503da7f31
|
File details
Details for the file pd_code_to_diagram-0.1.10-py3-none-any.whl.
File metadata
- Download URL: pd_code_to_diagram-0.1.10-py3-none-any.whl
- Upload date:
- Size: 77.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3ffb85f8763449a49cc61777abdf740ece2ef1606b2c87c527dbb17052224a6
|
|
| MD5 |
cd1807299e4b513fb6aa4d27ff1ec777
|
|
| BLAKE2b-256 |
bc06721bc5b5595a59b5c88e8a374b8b1ecd0241f79b1a09ffe2609cadac4304
|