rough


Namerough JSON
Version 1.5 PyPI version JSON
download
home_pageNone
SummaryHigh-quality 'hand drawn' vector graphics. Python port of Rough.js.
upload_time2025-02-12 05:53:07
maintainerNone
docs_urlNone
authorcktl.co
requires_python>=3.10
licenseMIT
keywords svg graphics rough.js python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<picture>
    <img src="https://raw.githubusercontent.com/cktlco/rough-py/main/resources/images/rough-py.svg" 
        alt="rough-py"
        width="500px" />
</picture>


> 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.

<picture>
    <img src="https://raw.githubusercontent.com/cktlco/rough-py/main/examples/example-quickstart.svg"
        alt="1. Install rough-py, 2. Draw some shapes, 3. Output SVG image" 
        width="800px" />
</picture>

## 🖌️ Install
```bash
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
<picture>
    <img src="https://raw.githubusercontent.com/cktlco/rough-py/main/examples/example-readme.svg" 
        alt="rough-py API code usage example" 
        width="800px" />
</picture>

```python
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](https://github.com/cktlco/rough-py/blob/main/API.md)

📚 [Examples Gallery](https://github.com/cktlco/rough-py/blob/main/examples/examples.md)

🎨 [Fill and Stroke Style Gallery](https://github.com/cktlco/rough-py/blob/main/examples/example-stylegallery.md)

Still desperate? There are even more examples ([1](https://github.com/cktlco/rough-py/blob/main/tests/test_roughjs_visual_tests.py), [2](https://github.com/cktlco/rough-py/blob/main/tests/test_detailed_shapes.py), [3](https://github.com/cktlco/rough-py/blob/main/tests/test_simple_svg_paths.py)) 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`](https://github.com/cktlco/rough-py/blob/main/tests/test_roughen_svg.py) which implements a functional but work-in-progress SVG file "roughener".


## Questions or Issues?
🔍 See the [FAQ page](https://github.com/cktlco/rough-py/blob/main/FAQ.md).

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



<br/><br/>
*Happy Roughening!*


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rough",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "svg, graphics, rough.js, python",
    "author": "cktl.co",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/17/a0/0525c487467f8ab2d8edb6cd4223d530dfd8c4cc981c371a7ffe33a10f21/rough-1.5.tar.gz",
    "platform": null,
    "description": "\n<picture>\n    <img src=\"https://raw.githubusercontent.com/cktlco/rough-py/main/resources/images/rough-py.svg\" \n        alt=\"rough-py\"\n        width=\"500px\" />\n</picture>\n\n\n> Python port of Rough.js \n\n### Create useful graphics with a \"hand drawn\" visual style\n\n You'll use `rough-py` to **programmatically generate graphics** for documentation or data visualization.\n\n<picture>\n    <img src=\"https://raw.githubusercontent.com/cktlco/rough-py/main/examples/example-quickstart.svg\"\n        alt=\"1. Install rough-py, 2. Draw some shapes, 3. Output SVG image\" \n        width=\"800px\" />\n</picture>\n\n## \ud83d\udd8c\ufe0f Install\n```bash\npip install rough\n```\n\nNo other python packages or third-party dependencies needed. Optionally, you can `pip install fonttools` to enable embedding font outlines into your SVG output.\n\n## \ud83d\udd8d\ufe0f Use\n<picture>\n    <img src=\"https://raw.githubusercontent.com/cktlco/rough-py/main/examples/example-readme.svg\" \n        alt=\"rough-py API code usage example\" \n        width=\"800px\" />\n</picture>\n\n```python\nfrom rough import canvas, Options\n\nc = canvas(600, 200)  # arbitrary units\n\n# purple arc using an SVG-style path\nswirl_path = \"M 30 150 C 80 30, 220 30, 270 150 S 370 270, 420 150\"\nc.path(swirl_path, Options(stroke=\"#8a2be2\", strokeWidth=4, roughness=2.5))\n\n# transparent rectangle\nc.rectangle(x=112, y=20, w=80, h=100, options=Options(fill=\"rgba(230, 250, 255, 0.3)\"))\n\n# arc in bright magenta\nc.arc(360, 80, 80, 80, 0, 3.14, False, Options(stroke=\"#ff66cc\", strokeWidth=3))\n\n# circle with pink fill\nc.circle(100, 80, 60, Options(fill=\"pink\", fillStyle=\"solid\", stroke=\"#444\", strokeWidth=3))\n\n# green filled polygon\npoints = [(150, 30), (270, 70), (250, 90), (210, 100)]\nc.polygon(points, Options(stroke=\"teal\", fill=\"#a3ffa3\", fillStyle=\"hachure\", strokeWidth=2, roughness=1))\n\n# broad orange stroke\nc.line(420, 20, 580, 100, Options(stroke=\"orange\", strokeWidth=4, roughness=1.2))\n\n# write to a SVG file\nsvg_data: str = c.as_svg(600, 150)\nwith open(\"/tmp/rough-example.svg\", \"w\") as f:\n    f.write(svg_data)\n```\n\n\n## Use the full API\n\ud83d\ude80 [API Documentation](https://github.com/cktlco/rough-py/blob/main/API.md)\n\n\ud83d\udcda [Examples Gallery](https://github.com/cktlco/rough-py/blob/main/examples/examples.md)\n\n\ud83c\udfa8 [Fill and Stroke Style Gallery](https://github.com/cktlco/rough-py/blob/main/examples/example-stylegallery.md)\n\nStill desperate? There are even more examples ([1](https://github.com/cktlco/rough-py/blob/main/tests/test_roughjs_visual_tests.py), [2](https://github.com/cktlco/rough-py/blob/main/tests/test_detailed_shapes.py), [3](https://github.com/cktlco/rough-py/blob/main/tests/test_simple_svg_paths.py)) in the `tests/` directory.\n\n## Limitations\n\n\ud83d\udeab  **No JavaScript-style Interactivity**\n\n\ud83d\udea7  **Will not roughen existing SVG files**. For those too proud to accept that, review [`tests/test_roughen_svg.py`](https://github.com/cktlco/rough-py/blob/main/tests/test_roughen_svg.py) which implements a functional but work-in-progress SVG file \"roughener\".\n\n\n## Questions or Issues?\n\ud83d\udd0d See the [FAQ page](https://github.com/cktlco/rough-py/blob/main/FAQ.md).\n\nFreely use the **Discussions** tab above for general questions, or use the **Issues** tab to report a problem.\n\n\n## All glory to:\n- Rough.js - https://github.com/rough-stuff/rough\n- svgelements SVG Path parser - https://github.com/meerk40t/svgelements\n\n\n\n<br/><br/>\n*Happy Roughening!*\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "High-quality 'hand drawn' vector graphics. Python port of Rough.js.",
    "version": "1.5",
    "project_urls": {
        "Homepage": "https://github.com/cktlco/rough-py",
        "Repository": "https://github.com/cktlco/rough-py"
    },
    "split_keywords": [
        "svg",
        " graphics",
        " rough.js",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6514aead5d2b22734662b61589ea351acf69d29f1b10278138af4fed5f6ae4dc",
                "md5": "89b4dd4470e9108e530e18575fbd0eb0",
                "sha256": "9c78371ba5ccb68f10e357bb71b5ffd4477b2b956b00760946978c0aef26d771"
            },
            "downloads": -1,
            "filename": "rough-1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89b4dd4470e9108e530e18575fbd0eb0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 40198,
            "upload_time": "2025-02-12T05:53:05",
            "upload_time_iso_8601": "2025-02-12T05:53:05.918062Z",
            "url": "https://files.pythonhosted.org/packages/65/14/aead5d2b22734662b61589ea351acf69d29f1b10278138af4fed5f6ae4dc/rough-1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "17a00525c487467f8ab2d8edb6cd4223d530dfd8c4cc981c371a7ffe33a10f21",
                "md5": "c7b939c1f40cde7083d26ba50e1a682b",
                "sha256": "e8eb321e9d3a25afcce1e14c3e790df536533fafcfb4808e233a62534add981a"
            },
            "downloads": -1,
            "filename": "rough-1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "c7b939c1f40cde7083d26ba50e1a682b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 34216,
            "upload_time": "2025-02-12T05:53:07",
            "upload_time_iso_8601": "2025-02-12T05:53:07.401421Z",
            "url": "https://files.pythonhosted.org/packages/17/a0/0525c487467f8ab2d8edb6cd4223d530dfd8c4cc981c371a7ffe33a10f21/rough-1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-12 05:53:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cktlco",
    "github_project": "rough-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rough"
}
        
Elapsed time: 0.39593s