style-light-choice
style-dark-choice 
Avatar
Gary
Vollink.com

12 Januaray 2006

Updated: 19 August 2019

GD ColorMixer Example

This project went up in 2006, and besides some very minor changes was mostly left alone until the end of 2016.  Work on the ColorMixer was very active from the end of 2016 through 2019.  There are a few features that I am still interested in adding.  See To Do below.

CGI On-The-Fly ColorMixer Graphic

Along the same lines as the Percent Bar, I created a color mixer.  The color mixer takes Red, Green and Blue values between 0 and 255, and shows the color mixture using three overlapping circles.

The Dynamic HTML portion of this project grew to three times the size of the original GD graphic and example, so the two have been separated into separate Docker images (and source files).  As of August 2019, the Dynamic HTML portion still needs more refactoring work, though that has started.  Both portions are available for download below.

GD Graphic

mix Graphic created from this link /cgi-bin/gd_colormix_graphic/w:420/r:255/g:100/b:150

Named gd_colormix_graphic.psgi.pl, the utility that creates the graphic above has no direct interface of its own.  It creates the graphic based on the path extensions of the URL.

Color Informaion

This page, gd_colormix.psgi.pl, is available interacively at /cgi-bin/gd_colormix.cgi. I set this up, primarily, for my own use.  It started as a built-in demo-mode for the GD program. 

All options can be passed to gd_colormix in the URL.  This takes all options that the graphic output will take, but also includes a large number of color information options.

Live Demo

/cgi-bin/gd_colormix.cgi

To Do

Features that I would still like to see added to this:

Source Code

The gd_colormix_graphic code can be used as a guide for someone else who wants to get started using Perl with GD.  You can download the code here:

Source Code License

CC BY-SA 4.0. This means you can use it and change it, but you must make your changes public, keep the same license, and give me original author credit.  From a practical stand-point, please e-mail me patches, I don't use public GIT at this time. 

Technical Details

The first version of my color-mixer only included colors from the file x11_rgb.txt, which is the basis of the original Netscape accepted web colors.  Thus, all of the color sets now supported by the color mixer program have the same syntactic rules.

# Comments marked by octothorpe (#)
# R     G     B   Color Name can have many words
255   255   255   White
Valid CSS!