cvs: peardoc /en/guide/developers recommendations.xml
| From: | Stefan Neufeind | Date: | Sun, 29 Feb 2004 10:01:19 +0000 |
| Subject: | cvs: peardoc /en/guide/developers recommendations.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-2799@lists.php.net to get a copy of this message | ||
neufeind Sun Feb 29 05:01:19 2004 EDT
Added files:
/peardoc/en/guide/developers recommendations.xml
Log:
initial commit
http://cvs.php.net/co.php/peardoc/en/guide/developers/recommendations.xml?r=1.1&p=1
Index: peardoc/en/guide/developers/recommendations.xml
+++ peardoc/en/guide/developers/recommendations.xml
<?xml version="1.0" encoding="iso-8859-1" ?>
<!-- $Revision: 1.1 $ -->
<chapter id="developers.recommendations">
<docinfo>
<author>
<firstname>Stefan</firstname>
<surname>Neufeind</surname>
</author>
<date>2004-02-29</date>
</docinfo>
<title>Recommendations</title>
<sect1 id="developers.recommendations.introduction">
<title>
Why recommendations?
</title>
<para>
The following recommendations describe topics which were discussed
and agreed upon by the PEAR-developers on the mailinglist pear-dev
and by the core-team. They aren't regulations that you need to follow
(e.g. in contrast to the <link linkend="standards">Coding
Stardards</link>) but are
intended as guidelines for a common API-scheme and easier package
interoperability. Please consider following them in your packages
where possible.
</para>
</sect1>
<sect1 id="developers.faq.colorrepresentation">
<title>
Color-representation inside PEAR-packages
</title>
<titleabbrev>
Color-representation
</titleabbrev>
<para>
We recommend that developers store and use an array-representation of
color-values in their PEAR-packages. All values are in the range of
0..255.
</para>
<sect2>
<title>RGB-presesentation</title>
<para>
An example using our "PEAR-green" would look like:
<example>
$color = array(0x33, 0x99, 0x00);
or
$color = array(51, 153, 0);
</example>
Please note that the internal, numerical representation of both forms
of the example are equal. The values represent the RGB (red, green,
blue) values. It was decided not to use "r", "g" and "b" and
indizes
for the array because allows for easier creation of color-arrays in
sourcecode, makes handling less complicated and is an already
commonly used array-representations for colors.
</para>
</sect2>
<sect2>
<title>RGB-representation with alpha-values</title>
<para>
Since this an extension of the RGB-representation above it's
recommended to use a forth value for alpha-channel-prepresentation.
An example of our pear-color with our "PEAR-green" with aprox. 80%
intensity would be:
<example>
$color = array(0x33, 0x99, 0x00, 0xCC);
</example>
For consistency the alpha-value is also from the range 0..255. A
value of 255 means fully opaque (full color-intensity, same as in RGB-
notation), 0 means fully transparent.
</para>
<para>
Please note this is in contrast to the alpha-value used by
imagecolorallocate(). Our alpha-representation was choosen for
consistency with the other RGB-values and because it's commonly
accepted practise in many other applications (image-processing tools,
...).
</para>
</sect2>
<sect2>
<title>Other color-representations than RGB(A)</title>
<para>
Since RGB/RGBA will used for graphic generation on a computer we
decided to leave out an optional type-identifier classifying colors
as RGB/RGBA. However for different color-representations an
identifier is needed. The optional identifier "type" can be added to
the color array.
<example>
$color = array(0x33, 0x99, 0x00, 0xCC, "type" => "RGB");
</example>
Currently the following types are definied, with array-indices from
0..n follwing the colornames in the table:
<table>
<tgroup cols="2">
<thead>
<row>
<entry>type</entry>
<entry>colornames</entry>
</row>
</thead>
<tbody>
<row>
<entry>RGB</entry>
<entry>red, green, blue</entry>
</row>
<row>
<entry>CYMK</entry>
<entry>cyan, yellow, magenta, black (key)</entry>
</row>
</tbody>
</tgroup>
</table>
Please note that also the RGBA-representation has the type "RGB"
since it's closely related.
</para>
</sect2>
<sect2>
<title>Conversion to/between the color-representations</title>
<para>
The PEAR-package <ulink url="http://pear.php.net/package/Image_Color">Image_Color</ulink>
will (hopefully soon) contain all needed functions to convert arbitrary
color-formats to the internal RGBA-representation and convert different
color-representations.
</para>
<para>
Status: Currently Image_Color already offers functions to convert
color-names (e.g. "green") and hex-representations-strings (e.g.
"#339900") to the PEAR-RGBA-format. We are working to get alpha-
channel support added hopefully soon and will later add funtions for
CYMK-conversion as well.
</para>
</sect2>
</sect1>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
sgml-namecase-general:t
sgml-general-insert-case:lower
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->