Skip to main content

random-shapes

Generate random shapes with ease.

This library is heavily inspired by this stackoverflow answer

Logo

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)

Random shape example

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")

Binary image example

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)

Source distribution for random-shapes 0.1.0
File Size Uploaded
random_shapes-0.1.0.tar.gz 580.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for random-shapes 0.1.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page