Skip to main content

High-quality 'hand drawn' vector graphics. Python port of Rough.js.

Project description

rough-py

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.

1. Install rough-py, 2. Draw some shapes, 3. Output SVG image

🖌️ 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

rough-py API code usage example
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

🚀 API Documentation

📚 Examples Gallery

🎨 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:



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

rough-1.6.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rough-1.6-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file rough-1.6.tar.gz.

File metadata

  • Download URL: rough-1.6.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rough-1.6.tar.gz
Algorithm Hash digest
SHA256 1b292fa26bc300609250ca5564f94cf01bdde074c3085b90d3742e0902afe4c8
MD5 9eb3ec6970c54f53967ac7802003e953
BLAKE2b-256 43b70813fa7917fe715bd26dd832185922deb8575fb2aaec1b40334ff01c2227

See more details on using hashes here.

Provenance

The following attestation bundles were made for rough-1.6.tar.gz:

Publisher: python-publish-pypi.yml on cktlco/rough-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rough-1.6-py3-none-any.whl.

File metadata

  • Download URL: rough-1.6-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.13.7

File hashes

Hashes for rough-1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fe23e614d177e62ede853ec60994ed38af558c4b8a90ff8b07cd44709dffb82c
MD5 2355be9e4f952a19f078a02dda0c1e08
BLAKE2b-256 2e4c2620ec4bf56be0db15c22069615816a20cde173aca6bcf921a079fd3db9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rough-1.6-py3-none-any.whl:

Publisher: python-publish-pypi.yml on cktlco/rough-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page