etk/class_etk__Color.html

276 lines
23 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>etk Library</title>
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="menu.css">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="container">
<h1><a href="index.html">etk library</a></h1>
<h4><a href="http://github.com/heeroyui/etk/">&nbsp;&nbsp;&nbsp;[ sources ]</a></h4>
<h3>API:</h3> <div id="menu">
<ul class="niveau1">
<li class="sousmenu"><a href="namespace_etk.html">etk</a>
<ul class="niveau2">
<li><a href="namespace_etk__color.html">color</a>
</li>
<li><a href="namespace_etk__tool.html">tool</a>
</li>
<li><a href="namespace_etk__archive.html">archive</a>
</li>
<li><a href="namespace_etk__theme.html">theme</a>
</li>
</ul>
</li>
<li><a href="namespace_u32char.html">u32char</a>
</li>
<li><a href="namespace_utf8.html">utf8</a>
</li>
<li><a href="namespace_std.html">std</a>
</li>
<li><a href="namespace_debug.html">debug</a>
</li>
</ul>
</div>
<br/><h3>Associate libraries:</h3><div id="menu">
<ul class="niveau1"><li><a href="../ewol/index.html">ewol</a></li>
</ul><ul class="niveau1"><li><a href="../ejson/index.html">ejson</a></li>
</ul><ul class="niveau1"><li><a href="../egami/index.html">egami</a></li>
</ul><ul class="niveau1"><li><a href="../ege/index.html">ege</a></li>
</ul><ul class="niveau1"><li><a href="../esvg/index.html">esvg</a></li>
</ul><ul class="niveau1"><li><a href="../exml/index.html">exml</a></li>
</ul></div>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</div>
</div>
<div class="container" id="content">
<h1>class: etk::Color</h1><hr/><h2>Description:</h2>
The color class is a template to abstract the color implementation choice.<br/>
It is important to note that the color choice denpznd on the level of developent.
For example :
<ul> Graphic application use:
<ul> Image in 3/4 bytes for rgb(a)
Color description in char : '#F6780FFF' or the equivalent number:0xF6780FFF
</ul> middleware will mainely use a the 4 separate value with 1 byte for each.
graphic interface (openGL) store image in 1/2/3/4 bytes color and interpolate it in 'n' float. And note that the user color is sored in float.
</ul>
Then with this class we abstract the transformation format and set an easy same way to use the color independing of the developpement level.<br/>
Some of the basic color is defined in the namespace: [namespace[etk::color]].
<br/><br/>
<h2>Associated Namespace:</h2><ul>
<a href="namespace_etk__color.html">color</a></ul>
<h2>Constructor and Destructor:</h2>
<pre>
+ <a class="code-function" href="#8031">Color</a> (<span class="code-type" >void</span> <span class="code-argument"></span>);<br/>+ <a class="code-function" href="#8033">Color</a> (<span class="code-type" >double</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >double</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >double</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >double</span> <span class="code-argument">_a</span>);<br/>+ <a class="code-function" href="#8038">Color</a> (<span class="code-type" >float</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_a</span>);<br/>+ <a class="code-function" href="#8043">Color</a> (<span class="code-type" >uint8_t</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_a</span>);<br/>+ <a class="code-function" href="#8048">Color</a> (<span class="code-type" >int</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_a</span>);<br/>+ <a class="code-function" href="#8053">Color</a> (<span class="code-type" >uint32_t</span> <span class="code-argument">_input</span>);<br/>+ <a class="code-function" href="#8055">Color</a> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;float&gt; & <span class="code-argument">_obj</span>);<br/>+ <a class="code-function" href="#8057">Color</a> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;uint8_t&gt; & <span class="code-argument">_obj</span>);<br/>+ <a class="code-function" href="#8059">Color</a> (<span class="code-storage-keyword">const</span> <a class="code-type" href="http://www.cplusplus.com/reference/string/string/">std::string</a> & <span class="code-argument">_input</span>);<br/></pre>
<br/>
<h2>Synopsis:</h2>
<pre>
+ Color&lt;MY_TYPE&gt; & <a class="code-function" href="#8061">operator =</a> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;MY_TYPE&gt; & <span class="code-argument">_input</span>);<br/>+ <span class="code-type" >bool</span> <a class="code-function" href="#8063">operator !=</a> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;MY_TYPE&gt; & <span class="code-argument">_obj</span>) <span class="code-storage-keyword">const</span>;<br/>+ <span class="code-type" >bool</span> <a class="code-function" href="#8065">operator ==</a> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;MY_TYPE&gt; & <span class="code-argument">_obj</span>) <span class="code-storage-keyword">const</span>;<br/>+ <span class="code-type" >uint32_t</span> <a class="code-function" href="#8067">get</a> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/>+ <span class="code-type" >void</span> <a class="code-function" href="#8069">set</a> (<span class="code-type" >float</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_a</span>);<br/>+ <span class="code-type" >void</span> <a class="code-function" href="#8074">set</a> (<span class="code-type" >uint8_t</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_a</span>);<br/>+ <span class="code-type" >void</span> <a class="code-function" href="#8079">set</a> (<span class="code-type" >int</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_a</span>);<br/>+ <a class="code-type" href="http://www.cplusplus.com/reference/string/string/">std::string</a> <a class="code-function" href="#8084">getHexString</a> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/>+ <a class="code-type" href="http://www.cplusplus.com/reference/string/string/">std::string</a> <a class="code-function" href="#8086">getString</a> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/>+ MY_TYPE <a class="code-function" href="#8088">r</a> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/>+ MY_TYPE <a class="code-function" href="#8090">g</a> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/>+ MY_TYPE <a class="code-function" href="#8092">b</a> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/>+ MY_TYPE <a class="code-function" href="#8094">a</a> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/>+ <span class="code-type" >void</span> <a class="code-function" href="#8096">setR</a> (MY_TYPE <span class="code-argument">_r</span>);<br/>+ <span class="code-type" >void</span> <a class="code-function" href="#8098">setG</a> (MY_TYPE <span class="code-argument">_g</span>);<br/>+ <span class="code-type" >void</span> <a class="code-function" href="#8100">setB</a> (MY_TYPE <span class="code-argument">_b</span>);<br/>+ <span class="code-type" >void</span> <a class="code-function" href="#8102">setA</a> (MY_TYPE <span class="code-argument">_a</span>);<br/></pre>
<br/>
<h2>Detail:</h2>
<a id="8031"/><a id="8033"/><h3>Color</h3><pre>
+ <span class="code-function">Color</span> (<span class="code-type" >void</span> <span class="code-argument"></span>);<br/></pre>
Constructor. It does not initialise element of class.<br/>
<br/>
<hr/>
<a id="8038"/><a id="8043"/><a id="8048"/><a id="8053"/><h3>Color</h3><pre>
+ <span class="code-function">Color</span> (<span class="code-type" >double</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >double</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >double</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >double</span> <span class="code-argument">_a</span>);<br/>+ <span class="code-function">Color</span> (<span class="code-type" >float</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_a</span>);<br/>+ <span class="code-function">Color</span> (<span class="code-type" >uint8_t</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_a</span>);<br/>+ <span class="code-function">Color</span> (<span class="code-type" >int</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_a</span>);<br/></pre>
Contructor with request initialisation.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_r</span> </td><td> Red color.</td></tr>
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_g</span> </td><td> Green color.</td></tr>
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_b</span> </td><td> Blue color.</td></tr>
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_a</span> </td><td> Alpha blending.</td></tr>
</table>
</ul>
<br/>
<hr/>
<a id="8055"/><h3>Color</h3><pre>
+ <span class="code-function">Color</span> (<span class="code-type" >uint32_t</span> <span class="code-argument">_input</span>);<br/></pre>
Constructor with the single integer input.<br/><b>Note:</b> Not forger the alpha blending at the end<br/> <ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_input</span> </td><td> rgba integer value : 0xrrggbbaa &gt;&gt; 0x99AF6DFF</td></tr>
</table>
</ul>
<br/>
<hr/>
<a id="8057"/><a id="8059"/><h3>Color</h3><pre>
+ <span class="code-function">Color</span> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;float&gt; & <span class="code-argument">_obj</span>);<br/>+ <span class="code-function">Color</span> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;uint8_t&gt; & <span class="code-argument">_obj</span>);<br/></pre>
Copy contructor or convert contructor<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_obj</span> </td><td> Element to copy in this new color class.</td></tr>
</table>
</ul>
<br/>
<hr/>
<a id="8061"/><h3>Color</h3><pre>
+ <span class="code-function">Color</span> (<span class="code-storage-keyword">const</span> <a class="code-type" href="http://www.cplusplus.com/reference/string/string/">std::string</a> & <span class="code-argument">_input</span>);<br/></pre>
String extractor constructor.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_input</span> </td><td> Color string to parse. it can be : "#rrggbb", "rgb", "rrggbbaa", "rgba", "blueviolet" ...</td></tr>
</table>
</ul>
<br/>
<hr/>
<a id="8063"/><h3>operator =</h3><pre>
+ Color&lt;MY_TYPE&gt; & <span class="code-function">operator =</span> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;MY_TYPE&gt; & <span class="code-argument">_input</span>);<br/></pre>
Asignemement operator<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_input</span> </td><td> Color object to set in this class.</td></tr>
<tr><td><b>Return: </b></td><td></td><td>reference on this element.</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8065"/><h3>operator !=</h3><pre>
+ <span class="code-type" >bool</span> <span class="code-function">operator !=</span> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;MY_TYPE&gt; & <span class="code-argument">_obj</span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Different comparaison operator.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_obj</span> </td><td> Color object to compare.</td></tr>
<tr><td><b>Return: </b></td><td></td><td>true This is not the same color&lt;br/&gt;false This is the same color.</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8067"/><h3>operator ==</h3><pre>
+ <span class="code-type" >bool</span> <span class="code-function">operator ==</span> (<span class="code-storage-keyword">const</span> <a class="code-type" href="class_etk__Color.html">etk::Color</a>&lt;MY_TYPE&gt; & <span class="code-argument">_obj</span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Equality comparaison operator.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_obj</span> </td><td> Color object to compare.</td></tr>
<tr><td><b>Return: </b></td><td></td><td>true This is the same color.&lt;br/&gt;false The color are different.</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8069"/><h3>get</h3><pre>
+ <span class="code-type" >uint32_t</span> <span class="code-function">get</span> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/></pre>
<ul>
<table class="parameter-list">
<tr><td><b>Return: </b></td><td></td><td>Color in unsigned integer</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8074"/><a id="8079"/><a id="8084"/><h3>set</h3><pre>
+ <span class="code-type" >void</span> <span class="code-function">set</span> (<span class="code-type" >float</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >float</span> <span class="code-argument">_a</span>);<br/>+ <span class="code-type" >void</span> <span class="code-function">set</span> (<span class="code-type" >uint8_t</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >uint8_t</span> <span class="code-argument">_a</span>);<br/>+ <span class="code-type" >void</span> <span class="code-function">set</span> (<span class="code-type" >int</span> <span class="code-argument">_r</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_g</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_b</span>,<br/> <span class="code-type" >int</span> <span class="code-argument">_a</span>);<br/></pre>
Set the specified color elements.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_r</span> </td><td> Red color.</td></tr>
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_g</span> </td><td> Green color.</td></tr>
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_b</span> </td><td> Blue color.</td></tr>
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_a</span> </td><td> Alpha blending.</td></tr>
</table>
</ul>
<br/>
<hr/>
<a id="8086"/><h3>getHexString</h3><pre>
+ <a class="code-type" href="http://www.cplusplus.com/reference/string/string/">std::string</a> <span class="code-function">getHexString</span> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Convert the color in an hexedecimal string ("0xFEDCBA98")<br/><ul>
<table class="parameter-list">
<tr><td><b>Return: </b></td><td></td><td>The formated string</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8088"/><h3>getString</h3><pre>
+ <a class="code-type" href="http://www.cplusplus.com/reference/string/string/">std::string</a> <span class="code-function">getString</span> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Convert the color in an generic string value ("#FEDCBA98")<br/><ul>
<table class="parameter-list">
<tr><td><b>Return: </b></td><td></td><td>The formated string</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8090"/><h3>r</h3><pre>
+ MY_TYPE <span class="code-function">r</span> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Get red color.<br/><ul>
<table class="parameter-list">
<tr><td><b>Return: </b></td><td></td><td>The red color.</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8092"/><h3>g</h3><pre>
+ MY_TYPE <span class="code-function">g</span> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Get green color.<br/><ul>
<table class="parameter-list">
<tr><td><b>Return: </b></td><td></td><td>The green color.</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8094"/><h3>b</h3><pre>
+ MY_TYPE <span class="code-function">b</span> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Get blue color.<br/><ul>
<table class="parameter-list">
<tr><td><b>Return: </b></td><td></td><td>The blue color.</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8096"/><h3>a</h3><pre>
+ MY_TYPE <span class="code-function">a</span> (<span class="code-type" >void</span> <span class="code-argument"></span>) <span class="code-storage-keyword">const</span>;<br/></pre>
Get alpha blending.<br/><ul>
<table class="parameter-list">
<tr><td><b>Return: </b></td><td></td><td>The alpha blending.</td></tr></table>
</ul>
<br/>
<hr/>
<a id="8098"/><h3>setR</h3><pre>
+ <span class="code-type" >void</span> <span class="code-function">setR</span> (MY_TYPE <span class="code-argument">_r</span>);<br/></pre>
Set red color.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_r</span> </td><td> The red color to set.</td></tr>
</table>
</ul>
<br/>
<hr/>
<a id="8100"/><h3>setG</h3><pre>
+ <span class="code-type" >void</span> <span class="code-function">setG</span> (MY_TYPE <span class="code-argument">_g</span>);<br/></pre>
Set green color.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_g</span> </td><td> The green color to set.</td></tr>
</table>
</ul>
<br/>
<hr/>
<a id="8102"/><h3>setB</h3><pre>
+ <span class="code-type" >void</span> <span class="code-function">setB</span> (MY_TYPE <span class="code-argument">_b</span>);<br/></pre>
Set blue color.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_b</span> </td><td> The blue color to set.</td></tr>
</table>
</ul>
<br/>
<hr/>
<h3>setA</h3><pre>
+ <span class="code-type" >void</span> <span class="code-function">setA</span> (MY_TYPE <span class="code-argument">_a</span>);<br/></pre>
Set alpha blending.<br/><ul>
<table class="parameter-list">
<td><b>Parameter [input]:</b></td><td><span class="code-argument">_a</span> </td><td> The alpha blending to set.</td></tr>
</table>
</ul>
<br/>
<hr/>
</div>
</body>
</html>