Skip to main content

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


Download files

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

Source Distribution

maige-0.0.3.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

maige-0.0.3-py3-none-any.whl (9.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page