
PLOT COLORINGBOOK
LAYER, COLOR OVERRIDE
WITH
BITMAP
"/Users/todlandis/proj/samples/sample0.png"
LAYERS "/Users/todlandis/proj/samples/overlays"
TRANSLUCENCE 100
PAGE 0 0 400 200
NO SIDES
NO YAXIS
SELECT "sample1", "red";
Entrance “coloring books” are an innovation with many possible applications, They make it possible to report query results by “painting” color on arbitrary collections of shapes. Think of countries, counties, and electoral districts. We used a coloring book to make the Red-Blue States Map in the previous post, for example.
The idea is for graphic artists, archtiects and others to use tools like AutoCad and PhotoShop to design these Entrance coloring books for use by MySQL developers in building applications.
To get the idea, consider the squiggle “chart” above. It consists of this bottom BITMAP:

A color, determined by a SQL query, is sprayed over it using this LAYER as a mask:

The BITMAP goes on the bottom, then each row in the query resultset provides a LAYER and color. LAYER names correspond to bitmap files in the LAYERS directory.
You don’t have to color inside the lines. For example, take this image:

spray blue on it, and you have:

PLOT COLORINGBOOK
LAYER, COLOR OVERRIDE
WITH
BITMAP “/Users/todlandis/proj/samples/sample0.png”
LAYERS “/Users/todlandis/proj/samples/overlays”
TRANSLUCENCE 100
NO SIDES
NO YAXIS
NO XAXIS
SELECT “sample1″, “red”
UNION
SELECT “sample2″, “blue”;
Some Details
The SELECT part of an Entrance PLOT command can be any MySQL SELECT command, ie. the UNION in the above example can be replaced by whatever SELECT statement you need.
Use TRANSLUCENCE to change the translucence of the paint: 0 is completely transparent, 255 is completely opaque, 100 is see through. (See through paint provides a way to tint the regions of the underlying image)
Use PAGE to set the dimensions of the output image in pixels. This gives you a way to size images for the iPhone for example (also see File | Save results as HTML…)
Beginning with version 1.5.6, paths in BITMAP and LAYERS can be relative to the current script directory, eg. this works:
BITMAP "sample0.png"
LAYERS "overlays"