Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Using a blend of Python and Maths for the creation of images

Project description


.. list-table::
:stub-columns: 1

* - project
- |license| |gitter|
* - code
- |travis| |coveralls| |black|
* - pypi
- |version| |supported-versions|

.. |travis| image::

.. |coveralls| image::

.. |black| image::

.. |version| image::
:alt: PyPI Package latest release

.. |supported-versions| image::
:alt: Supported versions

.. |license| image::
:alt: License

.. |gitter| image::
:alt: Join the chat at

**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

.. image:: /_static/examples/a-boat.png
:align: center
:width: 75%

.. image:: /img/a-boat.png
:align: center
:width: 75%

.. testcode:: readme-boat

from stylo.image import LayeredImage
from stylo.color import FillColor
from stylo.shape import Circle, Rectangle, Triangle
from stylo.domain.transform import translate

# Let's define some colours
black = FillColor("000000")
seablue = FillColor("0000ff")
white = FillColor("ffffff")
yellow = FillColor("ffff00")
red = FillColor("dd2300")

# Now for the shapes we will draw
sun = Circle(-7, 3.4, 1.5)
sea = Circle(0, -55, 55)
sails = Triangle((0.1, 0.6), (2.5, 0.6), (0.1, 3.5)) | Triangle((-0.1, 0.6), (-1.5, 0.6), (-0.1, 3.5))
boat = Rectangle(0, 0, 3.5, 1) | Triangle((1.75, -0.5), (1.75, 0.5), (2.25, 0.5))
mast = Rectangle(0, 2, 0.125, 3)

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

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

image.add_layer(sun, yellow)
image.add_layer(sea, seablue)
image.add_layer(boat, red)
image.add_layer(mast, black)
image.add_layer(sails, white)

image(1920, 1080, filename="docs/_static/examples/a-boat.png");


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

.. code::

$ pip install stylo

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


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

**Note:** While :code:`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.

Filename, size & hash SHA256 hash help File type Python version Upload date
stylo-0.6.0-py3-none-any.whl (41.0 kB) Copy SHA256 hash SHA256 Wheel py3 Oct 7, 2018
stylo-0.6.0.tar.gz (59.0 kB) Copy SHA256 hash SHA256 Source None Oct 7, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page