Sample Scripts

A good way to learn to use py_gd is to check out a few example scripts.

Ultra Simple Example

About the simplest example for py_gd

This draws a red line at a diagonal across an image.

_images/0-ultra_simple.png

Animation Example

This draws a bunch of dots in different colors and makes an animated gif of them.

_images/draw_dots.gif

Example with Moderate Complexity

py_gd demo with moderate complexity – showing a number of the features

Can you tell what’s being drawn from the code without looking at the results?

_images/moderate_complex.png

Using a Color Ramp

Example of how to use a colorramp

In this case, we plot a “Heatmap” of a surface from the equation:

z = sin(x) + sin(y)

_images/colorramp.png

Drawing a Madelbrot set

Draws a Madelbrot by setting colors pixel by pixel

_images/mandelbrot.png

Smooth Polygon

This example draws a star with rounded points, with varying roundedness.

It uses a “Spline Polygon:

_images/spline_star.png