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")
Metadata
Release files for random-shapes 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| random_shapes-0.1.0.tar.gz | 580.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| random_shapes-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 598.6 kB
Release files / random_shapes-0.1.0.tar.gz
| Download URL | random_shapes-0.1.0.tar.gz |
|---|---|
| Size | 580.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2379efbebafd78ea7b7b33f9ed29234465d1644c5d6c7a68de77e5661bc6d65
|
|
BLAKE2b-256 checksum How to use checksums |
d34e24f65bebff236236718f28140596ebaa65e7efce556fa847191ba8155ba6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.5.24
|
Release files / random_shapes-0.1.0-py3-none-any.whl
| Download URL | random_shapes-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2956680b1dc8430b203adea5baff8fc46a37d61f80bf69b8d359353a43320ef4
|
|
BLAKE2b-256 checksum How to use checksums |
87f02877d069ad4d77cb0ba340bc44b759889328aff9591fb1c875a893ef927f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.5.24
|