98 |
- |
1 |
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
|
|
|
2 |
<!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 — Select a color map</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">$plot->SetRGBArray(<em class="parameter"><code>$color_array</code></em>)</pre></div><div class="refsect1"><a id="idp1378726660"></a><h2>Description</h2><p>
|
|
|
3 |
<code class="function">SetRGBArray</code> selects a color map to use. A color map is
|
|
|
4 |
an array of color names available for use in the plot. You can select from
|
|
|
5 |
pre-defined color maps, or define your own. Each color in a color map has a
|
|
|
6 |
name, and 3 or 4 color component values (red, green, blue, and optional
|
|
|
7 |
alpha). The red, green, and blue components are in the range 0 through 255, and
|
|
|
8 |
the optional alpha component is in the range 0 through 127.
|
|
|
9 |
</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>
|
|
|
10 |
An array or a string. If an array, each element defines a color in the color
|
|
|
11 |
map. The array element key is the color name, and the array element value
|
|
|
12 |
is an array of three or four components. (See example below).
|
|
|
13 |
</p><p>
|
|
|
14 |
Or, a string selecting a built-in color map.
|
|
|
15 |
Use 'small' to select a map of 36 colors, or 'large'
|
|
|
16 |
to select a much larger color map.
|
|
|
17 |
</p></dd></dl></div></div><div class="refsect1"><a id="idp1378730036"></a><h2>Notes</h2><p>
|
|
|
18 |
If SetRGBArray is not called, the 'small' color map is used.
|
|
|
19 |
</p><p>
|
|
|
20 |
More information about the color maps can be found in
|
|
|
21 |
<a class="xref" href="conc-colors.html#conc-colors-map" title="3.5.2. Built-in Color Maps">Section 3.5.2, “Built-in Color Maps”</a>.
|
|
|
22 |
More information about using the alpha component can be found in
|
|
|
23 |
<a class="xref" href="adv-truecolor.html" title="4.3. Truecolor Images">Section 4.3, “Truecolor Images”</a>.
|
|
|
24 |
</p><p>
|
|
|
25 |
Color names are case sensitive.
|
|
|
26 |
</p><p>
|
|
|
27 |
For the large color map to be loaded with SetRGBArray('large'), the file
|
|
|
28 |
<code class="filename">rgb.inc.php</code> must be found on the PHP include path or
|
|
|
29 |
in the same directory as <code class="filename">phplot.php</code>.
|
|
|
30 |
This file is included in the PHPlot distribution.
|
|
|
31 |
</p><p>
|
|
|
32 |
You are not limited to using only the colors in the color map. The color
|
|
|
33 |
map defines which <span class="emphasis"><em>color names</em></span> you can use, and exactly
|
|
|
34 |
what they mean. You can also specify colors numerically.
|
|
|
35 |
</p><p>
|
|
|
36 |
PHPlot resolves a color name to its component values (red, green, blue) at
|
|
|
37 |
the time the element's color is set, using whatever color map is present at
|
|
|
38 |
that time. For PHPlot's default colors, this happens when the PHPlot object
|
|
|
39 |
is created. This means that changes to the color map affect only future color
|
|
|
40 |
settings. See the Color Resolution example below for more.
|
|
|
41 |
After using <code class="function">SetRGBArray</code>, you will probably want to define
|
|
|
42 |
element and data colors with the functions listed in
|
|
|
43 |
<a class="xref" href="ref-colorstyle.html" title="6.3. Colors and Line Styles">Section 6.3, “Colors and Line Styles”</a>.
|
|
|
44 |
</p></div><div class="refsect1"><a id="idp1378735108"></a><h2>Examples</h2><p>
|
|
|
45 |
An example of a user-defined color map is:
|
|
|
46 |
</p><pre class="programlisting">array( 'black' => array(0, 0, 0),
|
|
|
47 |
'white' => array(255, 255, 255),
|
|
|
48 |
'gray' => array(190, 190, 190),
|
|
|
49 |
'red' => array(255, 0, 0),
|
|
|
50 |
'green' => array(0, 255, 0),
|
|
|
51 |
'blue' => array(0, 0, 255) )
|
|
|
52 |
</pre><p>
|
|
|
53 |
</p><p>
|
|
|
54 |
The following example is provided for the note above on color resolution.
|
|
|
55 |
The main title will be black, the X title will be blue, and the Y title
|
|
|
56 |
will be green. This is because:
|
|
|
57 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
|
|
58 |
The main title color is defaulted, so it gets defined as black by the
|
|
|
59 |
PHPlot constructor. The later redefinition of <span class="emphasis"><em>black</em></span>
|
|
|
60 |
in the color array has no effect on this title.
|
|
|
61 |
</p></li><li class="listitem"><p>
|
|
|
62 |
The X title color is set to blue, using the default ('small') color map's
|
|
|
63 |
definition of <span class="emphasis"><em>blue</em></span> at that time.
|
|
|
64 |
</p></li><li class="listitem"><p>
|
|
|
65 |
The Y title color is green, because a new color map was loaded before the Y
|
|
|
66 |
title color was set, and that color map defines a color named
|
|
|
67 |
<span class="emphasis"><em>blue</em></span> as RGB #00ff00 which is green.
|
|
|
68 |
</p></li></ul></div><p>
|
|
|
69 |
</p><pre class="programlisting">$plot = new PHPlot();
|
|
|
70 |
...
|
|
|
71 |
$plot->SetXTitleColor('blue');
|
|
|
72 |
$plot->SetRGBArray(array('black' => array(255,0,0), 'blue' => array(0, 255, 0)));
|
|
|
73 |
$plot->SetYTitleColor('blue');
|
|
|
74 |
...
|
|
|
75 |
</pre><p>
|
|
|
76 |
</p></div><div class="refsect1"><a id="idp1378739812"></a><h2>History</h2><p>
|
|
|
77 |
Starting with PHPlot-6.0.0, specifying an invalid string for
|
|
|
78 |
<em class="parameter"><code>$color_array</code></em> results in an error message.
|
|
|
79 |
In older releases, a two color black/white color map would be loaded with
|
|
|
80 |
no error reported.
|
|
|
81 |
</p><p>
|
|
|
82 |
Versions of this manual written for releases before PHPlot-6.0.0
|
|
|
83 |
incorrectly stated that your color map must include the colors that PHPlot
|
|
|
84 |
uses as internal defaults (black, white, and gray), and incorrectly implied
|
|
|
85 |
that you could redefine existing colors (for example, change black to
|
|
|
86 |
(r=255,g=0,b=0) to make it red) and have that apply to the default element
|
|
|
87 |
colors. The actual behavior is as described in the note above about color
|
|
|
88 |
resolution.
|
|
|
89 |
</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>
|