High-quality 'hand drawn' vector graphics. Python port of Rough.js.
Project description
Python port of Rough.js
Create useful graphics with a "hand drawn" visual style
You'll use rough-py
to programmatically generate graphics for documentation or data visualization.
🖌️ Install
pip install rough
No other python packages or third-party dependencies needed. Optionally, you can pip install fonttools
to enable embedding font outlines into your SVG output.
🖍️ Use
from rough import canvas, Options
c = canvas(600, 200) # arbitrary units
# purple arc using an SVG-style path
swirl_path = "M 30 150 C 80 30, 220 30, 270 150 S 370 270, 420 150"
c.path(swirl_path, Options(stroke="#8a2be2", strokeWidth=4, roughness=2.5))
# transparent rectangle
c.rectangle(x=112, y=20, w=80, h=100, options=Options(fill="rgba(230, 250, 255, 0.3)"))
# arc in bright magenta
c.arc(360, 80, 80, 80, 0, 3.14, False, Options(stroke="#ff66cc", strokeWidth=3))
# circle with pink fill
c.circle(100, 80, 60, Options(fill="pink", fillStyle="solid", stroke="#444", strokeWidth=3))
# green filled polygon
points = [(150, 30), (270, 70), (250, 90), (210, 100)]
c.polygon(points, Options(stroke="teal", fill="#a3ffa3", fillStyle="hachure", strokeWidth=2, roughness=1))
# broad orange stroke
c.line(420, 20, 580, 100, Options(stroke="orange", strokeWidth=4, roughness=1.2))
# write to a SVG file
svg_data: str = c.as_svg(600, 150)
with open("/tmp/rough-example.svg", "w") as f:
f.write(svg_data)
Use the full API
🎨 Fill and Stroke Style Gallery
Still desperate? There are even more examples (1, 2, 3) in the tests/
directory.
Limitations
🚫 No JavaScript-style Interactivity
🚧 Will not roughen existing SVG files. For those too proud to accept that, review tests/test_roughen_svg.py
which implements a functional but work-in-progress SVG file "roughener".
Questions or Issues?
🔍 See the FAQ page.
Freely use the Discussions tab above for general questions, or use the Issues tab to report a problem.
All glory to:
- Rough.js - https://github.com/rough-stuff/rough
- svgelements SVG Path parser - https://github.com/meerk40t/svgelements
Happy Roughening!
Project details
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
File details
Details for the file rough-1.5.tar.gz
.
File metadata
- Download URL: rough-1.5.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e8eb321e9d3a25afcce1e14c3e790df536533fafcfb4808e233a62534add981a
|
|
MD5 |
c7b939c1f40cde7083d26ba50e1a682b
|
|
BLAKE2b-256 |
17a00525c487467f8ab2d8edb6cd4223d530dfd8c4cc981c371a7ffe33a10f21
|
Provenance
The following attestation bundles were made for rough-1.5.tar.gz
:
Publisher:
python-publish-pypi.yml
on cktlco/rough-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
rough-1.5.tar.gz
-
Subject digest:
e8eb321e9d3a25afcce1e14c3e790df536533fafcfb4808e233a62534add981a
- Sigstore transparency entry: 170533943
- Sigstore integration time:
-
Permalink:
cktlco/rough-py@a40d152ac0a37e605be35211aa88c53c23ce53f2
-
Branch / Tag:
refs/tags/v1.5
- Owner: https://github.com/cktlco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
python-publish-pypi.yml@a40d152ac0a37e605be35211aa88c53c23ce53f2
-
Trigger Event:
release
-
Statement type:
File details
Details for the file rough-1.5-py3-none-any.whl
.
File metadata
- Download URL: rough-1.5-py3-none-any.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9c78371ba5ccb68f10e357bb71b5ffd4477b2b956b00760946978c0aef26d771
|
|
MD5 |
89b4dd4470e9108e530e18575fbd0eb0
|
|
BLAKE2b-256 |
6514aead5d2b22734662b61589ea351acf69d29f1b10278138af4fed5f6ae4dc
|
Provenance
The following attestation bundles were made for rough-1.5-py3-none-any.whl
:
Publisher:
python-publish-pypi.yml
on cktlco/rough-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
rough-1.5-py3-none-any.whl
-
Subject digest:
9c78371ba5ccb68f10e357bb71b5ffd4477b2b956b00760946978c0aef26d771
- Sigstore transparency entry: 170533947
- Sigstore integration time:
-
Permalink:
cktlco/rough-py@a40d152ac0a37e605be35211aa88c53c23ce53f2
-
Branch / Tag:
refs/tags/v1.5
- Owner: https://github.com/cktlco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
python-publish-pypi.yml@a40d152ac0a37e605be35211aa88c53c23ce53f2
-
Trigger Event:
release
-
Statement type: