Generate random shapes with ease.
Project description
random-shapes
Generate random shapes with ease.
This library is heavily inspired by this stackoverflow answer
Installation
You can install random-shapes via pip:
pip install random-shapes
However, uv is recommended for installing python packages:
uv add random-shapes
Usage
Install the optional library matplotlib for visualization:
pip install random-shapes[viz]
# or
uv add random-shapes --extra viz
With random-shapes it is easy to generate a random shape (bezier.CurvedPolygon):
from random_shapes import Shape
shp = Shape.random(n=10, r=0.05, edgy=0.2)
# Shape.curve is a bezier.CurvedPolygon, since Shape is a just wrapper
shp.curve.plot(pts_per_edge=10)
This shape can then be turned into a binary image:
import matplotlib.pyplot as plt
binary_image = shp.rasterize(h=512, w=512)
plt.imshow(binary_image, cmap="gray")
Project details
Release history Release notifications | RSS feed
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 random_shapes-0.1.0.tar.gz.
File metadata
- Download URL: random_shapes-0.1.0.tar.gz
- Upload date:
- Size: 580.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2379efbebafd78ea7b7b33f9ed29234465d1644c5d6c7a68de77e5661bc6d65
|
|
| MD5 |
f19e82dc36a7d321682478ee317c8396
|
|
| BLAKE2b-256 |
d34e24f65bebff236236718f28140596ebaa65e7efce556fa847191ba8155ba6
|
File details
Details for the file random_shapes-0.1.0-py3-none-any.whl.
File metadata
- Download URL: random_shapes-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2956680b1dc8430b203adea5baff8fc46a37d61f80bf69b8d359353a43320ef4
|
|
| MD5 |
f0b8473bee5e5b58aa438973dd2a3b57
|
|
| BLAKE2b-256 |
87f02877d069ad4d77cb0ba340bc44b759889328aff9591fb1c875a893ef927f
|