Subversion Repositories cheapmusic

Rev

Blame | Last modification | View Log | RSS feed

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>SetRGBArray</title><link rel="stylesheet" type="text/css" href="phplotdoc.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="PHPlot Reference Manual" /><link rel="up" href="reference.html" title="PHPlot Function Reference" /><link rel="prev" href="SetPrintImage.html" title="SetPrintImage" /><link rel="next" href="SetShading.html" title="SetShading" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">SetRGBArray</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="SetPrintImage.html">Prev</a> </td><th width="60%" align="center">PHPlot Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="SetShading.html">Next</a></td></tr></table><hr /></div><div class="refentry"><a id="SetRGBArray"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">SetRGBArray</span></h2><p>SetRGBArray &#8212; Select a color map</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">$plot-&gt;SetRGBArray(<em class="parameter"><code>$color_array</code></em>)</pre></div><div class="refsect1"><a id="idp1378726660"></a><h2>Description</h2><p>
<code class="function">SetRGBArray</code> selects a color map to use. A color map is
an array of color names available for use in the plot. You can select from
pre-defined color maps, or define your own. Each color in a color map has a
name, and 3 or 4 color component values (red, green, blue, and optional
alpha). The red, green, and blue components are in the range 0 through 255, and
the optional alpha component is in the range 0 through 127.
    </p></div><div class="refsect1"><a id="idp1378728012"></a><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>$color_array</code></em></span></dt><dd><p>
An array or a string. If an array, each element defines a color in the color
map. The array element key is the color name, and the array element value
is an array of three or four components. (See example below).
          </p><p>
Or, a string selecting a built-in color map.
Use 'small' to select a map of 36 colors, or 'large'
to select a much larger color map.
          </p></dd></dl></div></div><div class="refsect1"><a id="idp1378730036"></a><h2>Notes</h2><p>
If SetRGBArray is not called, the 'small' color map is used.
    </p><p>
More information about the color maps can be found in
<a class="xref" href="conc-colors.html#conc-colors-map" title="3.5.2. Built-in Color Maps">Section 3.5.2, &#8220;Built-in Color Maps&#8221;</a>.
More information about using the alpha component can be found in
<a class="xref" href="adv-truecolor.html" title="4.3. Truecolor Images">Section 4.3, &#8220;Truecolor Images&#8221;</a>.
    </p><p>
Color names are case sensitive.
    </p><p>
For the large color map to be loaded with SetRGBArray('large'), the file
<code class="filename">rgb.inc.php</code> must be found on the PHP include path or
in the same directory as <code class="filename">phplot.php</code>.
This file is included in the PHPlot distribution.
    </p><p>
You are not limited to using only the colors in the color map. The color
map defines which <span class="emphasis"><em>color names</em></span> you can use, and exactly
what they mean. You can also specify colors numerically.
    </p><p>
PHPlot resolves a color name to its component values (red, green, blue) at
the time the element's color is set, using whatever color map is present at
that time. For PHPlot's default colors, this happens when the PHPlot object
is created. This means that changes to the color map affect only future color
settings.  See the Color Resolution example below for more.
After using <code class="function">SetRGBArray</code>, you will probably want to define
element and data colors with the functions listed in
<a class="xref" href="ref-colorstyle.html" title="6.3. Colors and Line Styles">Section 6.3, &#8220;Colors and Line Styles&#8221;</a>.
    </p></div><div class="refsect1"><a id="idp1378735108"></a><h2>Examples</h2><p>
An example of a user-defined color map is:
      </p><pre class="programlisting">array( 'black' =&gt; array(0, 0, 0),
       'white' =&gt; array(255, 255, 255),
       'gray'  =&gt; array(190, 190, 190),
       'red'   =&gt; array(255, 0, 0),
       'green' =&gt; array(0, 255, 0),
       'blue'  =&gt; array(0, 0, 255) )
</pre><p>
    </p><p>
The following example is provided for the note above on color resolution.
The main title will be black, the X title will be blue, and the Y title
will be green. This is because:
      </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
The main title color is defaulted, so it gets defined as black by the
PHPlot constructor. The later redefinition of <span class="emphasis"><em>black</em></span>
in the color array has no effect on this title.
          </p></li><li class="listitem"><p>
The X title color is set to blue, using the default ('small') color map's
definition of <span class="emphasis"><em>blue</em></span> at that time.
          </p></li><li class="listitem"><p>
The Y title color is green, because a new color map was loaded before the Y
title color was set, and that color map defines a color named
<span class="emphasis"><em>blue</em></span> as RGB #00ff00 which is green.
          </p></li></ul></div><p>
      </p><pre class="programlisting">$plot = new PHPlot();
...
$plot-&gt;SetXTitleColor('blue');
$plot-&gt;SetRGBArray(array('black' =&gt; array(255,0,0), 'blue' =&gt; array(0, 255, 0)));
$plot-&gt;SetYTitleColor('blue');
...
</pre><p>
    </p></div><div class="refsect1"><a id="idp1378739812"></a><h2>History</h2><p>
Starting with PHPlot-6.0.0, specifying an invalid string for
<em class="parameter"><code>$color_array</code></em> results in an error message.
In older releases, a two color black/white color map would be loaded with
no error reported.
    </p><p>
Versions of this manual written for releases before PHPlot-6.0.0
incorrectly stated that your color map must include the colors that PHPlot
uses as internal defaults (black, white, and gray), and incorrectly implied
that you could redefine existing colors (for example, change black to
(r=255,g=0,b=0) to make it red) and have that apply to the default element
colors. The actual behavior is as described in the note above about color
resolution.
    </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="SetPrintImage.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="SetShading.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">SetPrintImage </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> SetShading</td></tr></table></div></body></html>