Skip to main content

Drawing images with a blend of Python and Mathematics

Project description

Stylo

Project MIT License Gitter
Docs Documentation Status
Code Travis Coveralls Black
PyPi PyPi Version PyPi Supported Versions

Stylo is in early development, while it is useable we cannot make any stability guarantees.

Stylo is a Python library that allows you to create images and animations powered by your imagination and a little mathematics. While mathematics is very much at the core you do not have to be a mathematician to use it!

For example here is a simple image of a boat that can be made with just a few lines of Python

A Boat

import stylo as st

# Let's define the shapes we want to draw
sun = st.Circle(-7, 3.4, 1.5, fill=True)
sea = st.Circle(0, -55, 55, fill=True)
sails = st.Triangle((0.1, 0.6), (2.5, 0.6), (0.1, 3.5)) | st.Triangle((-0.1, 0.6), (-1.5, 0.6), (-0.1, 3.5))
boat = st.Rectangle(0, 0, 3.5, 1) | st.Triangle((1.75, -0.5), (1.75, 0.5), (2.25, 0.5))
mast = st.Rectangle(0, 2, 0.125, 3)

# Move some into position
boat = boat >> st.translate(0, -2)
sails = sails >> st.translate(0, -2)
mast = mast >> st.translate(0, -2)

# Finally let's bring it all together
image = st.LayeredImage(background="99ddee", scale=8)

image.add_layer(sun, "ffff00")
image.add_layer(sea, "0000ff")
image.add_layer(boat, "dd2300")
image.add_layer(mast, "000000")
image.add_layer(sails, "ffffff")

image(1920, 1080, filename="a-boat.png")

Installation

Stylo is available for Python 3.5+ and can be installed using Pip:

$ pip install stylo

Be sure to check out the documentation (under construction) for details on how to get started with stylo.

Contributing

Contributions are welcome! Be sure to checkout the Contributing section of the documentation to get started.

Note: While stylo itself supports Python 3.5+, due to some of the development tools we use you need to have Python 3.6+ in order to contribute code to the library. Other versions of Python work just as well if you are looking to contribute documentation.

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

stylo-0.9.3.tar.gz (34.0 kB view hashes)

Uploaded Source

Built Distribution

stylo-0.9.3-py3-none-any.whl (116.8 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