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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

random_shapes-0.1.0.tar.gz (580.9 kB view details)

Uploaded Source

Built Distribution

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

random_shapes-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

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

Hashes for random_shapes-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b2379efbebafd78ea7b7b33f9ed29234465d1644c5d6c7a68de77e5661bc6d65
MD5 f19e82dc36a7d321682478ee317c8396
BLAKE2b-256 d34e24f65bebff236236718f28140596ebaa65e7efce556fa847191ba8155ba6

See more details on using hashes here.

File details

Details for the file random_shapes-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for random_shapes-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2956680b1dc8430b203adea5baff8fc46a37d61f80bf69b8d359353a43320ef4
MD5 f0b8473bee5e5b58aa438973dd2a3b57
BLAKE2b-256 87f02877d069ad4d77cb0ba340bc44b759889328aff9591fb1c875a893ef927f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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