SetTransparentColor — Designate one color to be transparent




SetTransparentColor designates one color in the image to be transparent. The designated color will not be visible (assuming the image is viewed with a program which supports transparency) - instead, everything drawn in that color will be transparent. By default, no color is transparent.



Color value to designate as transparent. See Section 3.5, “Colors” for more on color values. If this parameter is omitted or NULL, the default behavior of not having a transparent color is restored.


This will only work if both the selected image file format (see SetFileFormat) and the user's browser or viewer support transparency. GIF format supports transparency. PNG format also supports transparency, but viewer support is more limited.

As an alternative to designating a single color as transparent, you can control the transparency, or alpha value, of any color. See Section 4.3, “Truecolor Images” for more information.

An image either has a transparent color or it does not. (This is aside from use of alpha values for colors.) If you designate 'yellow' as transparent, for example, everything drawn on the image in yellow becomes transparent, regardless of when it was drawn - before or after the transparent color selection. This is because the transparent color designation occurs in the image's color map - it does not change the pixels in the image.


To set the plot image background to be transparent, pick a color (here 'yellow') that won't be used anywhere else on the image, and use code like this:



The ability to specify NULL or omit the parameter to disable having a transparent color was added in PHPlot-6.0.0. Logo

This version of the manual was produced for the PHPlot Sourceforge project web service site, which requires the logo on each page.

To download a logo-free copy of the manual, see the PHPlot project downloads area.