Generate beautiful images and animations using mathematical formulae.
Project description
maige
Maige is a package to generate images using mathematical functions, written in pure python. It uses numpy and matplotlib to create images and animations for different formulae. A user can provide their own functions that they would like to plot or use the inbuilt random function generator to generate outputs. A random algebraic function is generated using an Expression Tree that uses various functions provided by numpy. The user can also provide a set of points that they want to plot, instead of using the default set of points. Since the library is built on matplotlib, it can project the output in any projection that is accepted by matplotlib
.
Usage
Basic Usage
from maige.generator import Generator
g = Generator()
g.generate_image()
Projection
from maige.generator import Generator
g = Generator(projection="rectilinear")
g.generate_image()
Custom Function
from maige.generator import Generator
xfunc = lambda X, Y: X**2 * np.sin(Y**2)
yfunc = lambda X, Y: Y**3 - np.cos(X**2)
g = Generator(
projection="rectilinear",
xfunc=xfunc,
yfunc=yfunc,
)
fig, ax = g.generate_image("./examples/custom_func.png")
Custom Range
xfunc = lambda X, Y: X**2 * np.sin(Y**2)
yfunc = lambda X, Y: Y**3 - np.cos(X**2)
xrange = np.arange(0, np.pi, 0.01)
yrange = np.arange(0, np.pi, 0.01)
g = Generator(
projection="polar",
xfunc=xfunc,
yfunc=yfunc,
xrange=xrange,
yrange=yrange,
)
fig, ax = g.generate_image("./examples/custom_range.png")
Color
g = Generator(
pointcolor="#000000",
background="#FA7070",
projection="polar",
)
fig, ax = g.generate_image("./examples/custom_color.png")
Animation
xfunc = lambda X, Y: X**2 * np.sin(Y**2)
yfunc = lambda X, Y: Y**3 - np.cos(X**2)
xrange = np.arange(0, np.pi, 0.01)
yrange = np.arange(0, np.pi, 0.01)
g = Generator(
pointcolor="#ffffff",
background="#000000",
projection="polar",
xfunc=xfunc,
yfunc=yfunc,
)
g.generate_animation("./examples/anim_example.gif", init_cond="uniform")
Reproducibility
Images and animations can be reproduced by using the JSON stored on the first creation. One can also pass an integer seed to reproduce the same designs over multiple runs.
from maige.generator import Generator
g = Generator(
seed="./examples/rectilinear.json",
)
fig, ax = g.generate_image("./examples/rectilinear_2.png")
Installation
PyPI
maige
can be installed directly from PyPI by using pip
or pipenv
pip install maige
or
pipenv install maige
Source
Pipfile
and requirements.txt
are provided to install virtual environment using pipenv
or pip
. This can be done by following steps:
$ git clone https://github.com/chahak13/maige.git
$ cd maige
$ pipenv shell
$ pipenv install
If you're pip
instead of pipenv
, change the last command to pip install -r requirements.txt
.
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
File details
Details for the file maige-0.0.3.tar.gz
.
File metadata
- Download URL: maige-0.0.3.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46568d96f46c518730ee44cbead96318ec952440fff8a7f0f14b793b2163e2f5 |
|
MD5 | 073639fa2e473f4677d91fda100c2aed |
|
BLAKE2b-256 | 3499ff973d0d66e9338026c0a654a70bace74097b40182c1329d23b60259ccdf |
File details
Details for the file maige-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: maige-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4f385f8281216298de7727c9f51134b76af879e34149a40d476189cf3eef495 |
|
MD5 | 135c6a137352d1a4e87e368d08e1e6ab |
|
BLAKE2b-256 | 1a2e3036aa954d6d09ccdae9b1214bb1bed8f7fe1e540ac4657f0972cdcbc1e2 |