Gradients is a stupid simple Python script that allows you to generate a gradient image between two user-specified colors. The gradient is divided into a user-defined number of “stops” or segments, each of which is a blend of the two input colors.

How it works

The script uses linear interpolation in the RGB color space to calculate the color at each stop. Each stop is then drawn as a rectangle on an image, and the hexadecimal color of the stop is written at the bottom of the rectangle. The final image is saved as ‘gradient.png’.

Usage

To use the script, simply run it and follow the prompts to input the first and second colors in hexadecimal format and the number of stops. The script will then generate and save the gradient image.

Dependencies

The script uses the colour library to handle color conversions and interpolations, the numpy library for numerical operations, and the PIL (Python Imaging Library) library to create and save the image.

© David Stephenson