This section is a basic tutorial for generativepy.
If you are new to generativepy, it is worth reading through the tutorials in order, to gain an understanding of how to use the library.
generativepy supports several different types of image creation:
- Vector images, which can be used to create all types of geometric art. It uses the Pycairo library, which provides a comprehensive set of vector drawing tools to produce very high-quality graphics.
- See the Getting started article to start leaning about creating vector graphics.
- Bitmap images, which can be used to create various types of pixel art. This uses two libraries:
- Pillow, an image processing library that provides a wide range of functions for manipulating images, similar to the sort of functions you might use in programs like GIMP or Photoshop.
- NumPy, which stores images as a data array. It is more suited to performing heavy-duty maths on image pixels, for example creating certain types of fractals.
- 3D images, using the ModernGL library, which supports modern OpenGL. This is still at quite an experimental stage.
Each of these modes supports a common interchange format, the frame, which is actually a NumPy array. This allows for the exchange of data between the different modes.
In addition, generativepy supports:
- Image sequences, which work by calling one of the above modes repeatedly to create a sequence of images. This can be stored as a set of PNG files (that can be converted to a movie using ffmpeg or similar), or an animated GIF file.
- Mathematical extensions for vector imaging, which can be used to create various graphs and geometric diagrams, that can also be stored as images or movies.
There are also some support modules:
- color, a module that provides common colour handling across the different modes, including support for named colours, HSL, and alpha. It also supports colour maps that can be used, for example, to colourise fractals.
- tween, a module that supports basic tweening of numerical values and vector quantities (such as positions and colours).**
Join the PythonInformer Newsletter
Sign up using this form to receive an email when new content is added:
2d arrays abstract data type alignment and angle animation arc array arrays bar chart bar style behavioural pattern bezier curve built-in function callable object chain circle classes clipping close closure cmyk colour combinations comparison operator comprehension context context manager conversion count creational pattern data science data types decorator design pattern device space dictionary drawing duck typing efficiency ellipse else encryption enumerate fill filter font font style for loop formula function function composition function plot functools game development generativepy tutorial generator geometry gif global variable gradient greyscale higher order function hsl html image image processing imagesurface immutable object in operator index inner function input installing iter iterable iterator itertools join l system lambda function len lerp line line plot line style linear gradient linspace list list comprehension logical operator lru_cache magic method mandelbrot mandelbrot set map marker style matplotlib monad mutability named parameter numeric python numpy object open operator optimisation optional parameter or pandas partial application path pattern permutations pie chart pil pillow polygon pong positional parameter print product programming paradigms programming techniques pure function python standard library radial gradient range recipes rectangle recursion reduce regular polygon repeat rgb rotation roundrect scaling scatter plot scipy sector segment sequence setup shape singleton slice slicing sound spirograph sprite square str stream string stroke structural pattern subpath symmetric encryption template text text metrics tinkerbell fractal transform translation transparency triangle truthy value tuple turtle unpacking user space vectorisation webserver website while loop zip zip_longest