/usr/share/doc/python-gdchart2-doc/doc/colours.html is in python-gdchart2-doc 0.beta1-3.4ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | <html>
<head>
<LINK REL=StyleSheet HREF="./style/style.css" TYPE="text/css">
</head>
<a href="pies/options.html"><--previous</a> |
<a href="./index.html">contents</a> |
<a href="admin.html">next--></a>
<hr>
<body>
<h1>Colours</h1>
<p> Both PyGDChart and GDChart itself store and manipulate colours as RGB
integers. Users will be familiar with RGB colour definitions from other
contexts - for instance, colours in HTML are often specified in the form
"#RRGGBB", where each component is a hex number between 0 and 256. Since the
naked RGB integer is cumbersome to work with, the PyGDChart library provides a
number of simple facilities to make the programmer's life easier.</p>
<h2> The RGB Class </h2>
<p> The first of the colour manipulation facilities provided by PyGDChart is
the RGB class. This class is simply a way to collect and manipulate the
components of a normal RGB colour definition. It is instantiated as
follows:</p>
<code>
<table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#B82619">
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" bgcolor="#FFFFFF" width="100%">
<tr>
<td valign="top">
<pre><font color="#000000">x</font> <font color="#0000C0">=</font> <font color="#000000">gdchart</font><font color="#0000C0">.</font><font color="#000000">RGB</font><font color="#0000C0">(</font><font color="#000000">r</font><font color="#0000C0">,</font> <font color="#000000">g</font><font color="#0000C0">,</font> <font color="#000000">b</font><font color="#0000C0">)</font><font color="#000000"></font></pre>
</td>
</tr>
</table>
</td>
</tr>
</table>
</code>
<p> After instantiation, an RGB object exposes the attributes r, g, and b,
which can be inspected and set independently. RGB objects have an __int__
method that converts the RGB colour definition to the correct numerical value.
As such, an RGB object can be used wherever a colour definition is
required.</p>
<h2> The rgbFactory() function </h2>
<p> The rgbFactory() function is an easy way to manufacture RGB objects
corresponding to common colours: </p>
<code>
<table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#B82619">
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" bgcolor="#FFFFFF" width="100%">
<tr>
<td valign="top">
<pre><font color="#000000">x</font> <font color="#0000C0">=</font> <font color="#000000">gdchart</font><font color="#0000C0">.</font><font color="#000000">rgbFactory</font><font color="#0000C0">(</font><font color="#004080">"blue"</font><font color="#0000C0">)</font><font color="#000000"></font></pre>
</td>
</tr>
</table>
</td>
</tr>
</table>
</code>
<p> At the moment only entries for "blue", "red", "green", "orange", "white",
"black" and "yellow" are provided, but this list will grow in future.</p>
<h2> Colours and PyGDChart</h2>
<p> From the preceding sections, we already know of two major ways to specify a
colour to PyGDChart. Firstly, as a plain integer:</p>
<code>
<table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#B82619">
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" bgcolor="#FFFFFF" width="100%">
<tr>
<td valign="top">
<pre><font color="#000000">x</font><font color="#0000C0">.</font><font color="#000000">bg_color</font> <font color="#0000C0">=</font> <font color="#0080C0">0x3232CC</font><font color="#000000"></font></pre>
</td>
</tr>
</table>
</td>
</tr>
</table>
</code>
<p> And secondly, as an RGB object:</p>
<code>
<table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#B82619">
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" bgcolor="#FFFFFF" width="100%">
<tr>
<td valign="top">
<pre><font color="#000000">x</font><font color="#0000C0">.</font><font color="#000000">bg_color</font> <font color="#0000C0">=</font> <font color="#000000">gdchart</font><font color="#0000C0">.</font><font color="#000000">rgbFactory</font><font color="#0000C0">(</font><font color="#004080">"blue"</font><font color="#0000C0">)</font><font color="#000000"></font></pre>
</td>
</tr>
</table>
</td>
</tr>
</table>
</code>
<p> From the latter example, however, an even more convenient way of specifying
a colour leaps to mind. Since options in PyGDChart are "smart", we can check
wether an option has been passed a string, and call rgbFactory automatically to
generate an RGB object. This leads us to the third way of specifying colours in
PyGDChart - simply by using a descriptive string:</p>
<code>
<table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#B82619">
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" bgcolor="#FFFFFF" width="100%">
<tr>
<td valign="top">
<pre><font color="#000000">x</font><font color="#0000C0">.</font><font color="#000000">bg_color</font> <font color="#0000C0">=</font> <font color="#004080">"blue"</font><font color="#000000"></font></pre>
</td>
</tr>
</table>
</td>
</tr>
</table>
</code>
</body>
<hr>
<table width="100%">
<tr>
<td>
<a href="pies/options.html"><--previous</a> |
<a href="./index.html">contents</a> |
<a href="admin.html">next--></a>
</td>
<td align="right">
(12/31/03)
</td>
</tr>
</table>
<center> PyGDChart User's Manual </center>
</html>
|