identiconpp/docs/index.html

179 lines
11 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>identiconpp: Main Page</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">identiconpp
&#160;<span id="projectnumber">0.7.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">identiconpp Documentation</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>identiconpp</b> is a library to generate identicons for C++.</p>
<p>You get the images as <code>Magick::Image</code>. This allows you to make all kinds of modifications.</p>
<img src="https://doc.schlomp.space/identiconpp/identicon1.png" title="4x4 identicon, ltr_symmetric, 20px padding" alt="" class="inline"/>
<img src="https://doc.schlomp.space/identiconpp/identicon2.png" title="5x5 identicon, sigil" alt="" class="inline"/>
<img src="https://doc.schlomp.space/identiconpp/identicon3.png" title="5x5 identicon, ltr_asymmetric" alt="" class="inline"/>
<img src="https://doc.schlomp.space/identiconpp/identicon4.png" title="6x4 identicon, ltr_symmetric, 10px padding" alt="" class="inline"/>
<p>The example images above are generated using <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/examples/example.cpp">example.cpp</a>.</p>
<h2>Features</h2>
<ul>
<li>[x] Symmetric identicons</li>
<li>[x] sigil identicons</li>
<li>[x] Asymmetric identicons</li>
<li>[x] Padding</li>
</ul>
<h2>Usage</h2>
<p>The HTML reference can be generated with <code>build_doc.sh</code>, if doxygen is installed. It is also available at <a href="https://doc.schlomp.space/identiconpp/classIdenticonpp.html">doc.schlomp.space/identiconpp/</a>.</p>
<p>You need to generate hashes yourself, any hexadecimal string will do. Make sure to use a safe hashing algorithm for sensitive data (<b>not MD5</b>). You can select as many columns and rows as you like, but make sure you have enough entropy. If something seems to be wrong, exceptions will be thrown.</p>
<p>The "sigil" algorithm generates the same results as <a href="https://github.com/cupcake/sigil/">sigil</a> and <a href="https://github.com/azaghal/pydenticon/">pydenticon</a>.</p>
<h3>Example</h3>
<div class="fragment"><div class="line">// Compile with g++ $(pkg-config --libs --cflags identiconpp)</div><div class="line">#include &lt;iostream&gt;</div><div class="line">#include &lt;identiconpp.hpp&gt;</div><div class="line">#include &lt;Magick++/Image.h&gt;</div><div class="line"></div><div class="line">int main()</div><div class="line">{</div><div class="line"> Identiconpp identicon(5, 5, Identiconpp::algorithm::ltr_symmetric,</div><div class="line"> &quot;ffffff80&quot;, { &quot;800000ff&quot; }, { 10, 10 });</div><div class="line"> Magick::Image img;</div><div class="line"> img = identicon.generate(&quot;55502f40dc8b7c769880b10874abc9d0&quot;, 200);</div><div class="line"> img.write(&quot;identicon.png&quot;);</div><div class="line"></div><div class="line"> std::cout &lt;&lt; identicon.generate_base64(&quot;png&quot;, &quot;5550&quot;, 200) &lt;&lt; std::endl;</div><div class="line">}</div></div><!-- fragment --><h2>Install</h2>
<h3>Gentoo</h3>
<p>Gentoo ebuilds are available via my <a href="https://schlomp.space/tastytea/overlay">repository</a>.</p>
<h3>Automatically generated packages</h3>
<p>Binary packages are generated automatically for each <a href="https://schlomp.space/tastytea/identiconpp/releases">release</a> in the formats <code>deb</code> and <code>rpm</code>. They are signed with my <a href="https://tastytea.de/tastytea_autosign.asc">automatic signing key</a>.</p>
<h3>From source</h3>
<h4>Dependencies</h4>
<ul>
<li>C++ compiler (tested: <a href="https://gcc.gnu.org/">gcc</a> 6/8/9, <a href="https://llvm.org/">clang</a> 7)</li>
<li><a href="https://cmake.org/">cmake</a> (at least 3.6)</li>
<li><a href="https://www.imagemagick.org/">imagemagick</a> (tested: 7.0 / 6.7)</li>
<li>Optional:<ul>
<li>Tests: <a href="https://github.com/catchorg/Catch2">Catch</a> (tested: 2.3 / 1.2)</li>
</ul>
</li>
</ul>
<p>On a Debian system, install the packages: <code>build-essential cmake libmagick++-dev</code>.</p>
<h4>Compile</h4>
<div class="fragment"><div class="line">mkdir build</div><div class="line">cd build</div><div class="line">cmake ..</div><div class="line">make</div><div class="line">make install</div></div><!-- fragment --><h5>cmake options</h5>
<ul>
<li><code>-DCMAKE_BUILD_TYPE=Debug</code> for a debug build</li>
<li><code>-DWITH_TESTS=YES</code> to build tests</li>
<li>One of:<ul>
<li><code>-DWITH_DEB=YES</code> to generate a deb-package</li>
<li><code>-DWITH_RPM=YES</code> to generate an rpm-package</li>
</ul>
</li>
</ul>
<p>To generate a binary package, execute <code>make package</code></p>
<h2>Contributing</h2>
<p>See <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/CONTRIBUTING.adoc">CONTRIBUTING.adoc</a></p>
<h2>Contact</h2>
<p>See <a href="https://tastytea.de/">https://tastytea.de/</a></p>
<h2>License &amp; Copyright</h2>
<div class="fragment"><div class="line">Copyright © 2018, 2019 tastytea &lt;tastytea@tastytea.de&gt;.</div><div class="line">License GPLv3: GNU GPL version 3 &lt;https://www.gnu.org/licenses/gpl-3.0.html&gt;.</div><div class="line">This program comes with ABSOLUTELY NO WARRANTY. This is free software,</div><div class="line">and you are welcome to redistribute it under certain conditions.</div></div><!-- fragment --><h2>Algorithms</h2>
<h3>ltr_symmetric</h3>
<ul>
<li>Create image with width=columns, height=rows.</li>
<li>Set background color.</li>
<li>Select half of the columns, or half of the columns + 1 if uneven.<ul>
<li><code>columns / 2 + columns % 2</code></li>
</ul>
</li>
<li>Pixels are drawn from left to right, top to bottom.</li>
<li>Use bits from digest to determine if a pixel is painted(1) or not(0).</li>
<li>Mirror the pixels vertically.</li>
<li>Use the following bits to pick the foreground color.<ul>
<li>You need <code>floor(log2(n_colors)) + 1</code> bits.</li>
</ul>
</li>
<li>Scale image proportionally to requested width.</li>
</ul>
<div class="fragment"><div class="line"> 0111 0011 1101 1100 […] 1111 0111 0101 0111</div><div class="line">^ ^</div><div class="line">+----------------------------+--------------&gt;</div><div class="line"> | |</div><div class="line"> pixel matrix foreground color</div></div><!-- fragment --><p>Implemented in <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_symmetric.cpp">ltr_symmetric.cpp</a></p>
<h3>ltr_asymmetric</h3>
<ul>
<li>Create image with width=columns, height=rows.</li>
<li>Set background color.</li>
<li>Pixels are drawn from left to right, top to bottom.</li>
<li>Use bits from digest to determine if a pixel is painted(1) or not(0).</li>
<li>Use the following bits to pick the foreground color.<ul>
<li>You need <code>floor(log2(n_colors)) + 1</code> bits.</li>
</ul>
</li>
<li>Scale image proportionally to requested width.</li>
</ul>
<div class="fragment"><div class="line"> 0111 0011 1101 1100 […] 1111 0111 0101 0111</div><div class="line">^ ^</div><div class="line">+----------------------------+--------------&gt;</div><div class="line"> | |</div><div class="line"> pixel matrix foreground color</div></div><!-- fragment --><p>Implemented in <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_asymmetric.cpp">ltr_asymmetric.cpp</a></p>
<h3>sigil</h3>
<ul>
<li>Create image with width=columns, height=rows.</li>
<li>Set background color.</li>
<li>Select half of the columns, or half of the columns + 1 if uneven.<ul>
<li><code>columns / 2 + columns % 2</code></li>
</ul>
</li>
<li>Pixels are drawn from top to bottom, left to right.</li>
<li>Use the first 8 bits to pick the foreground color.</li>
<li>Use the following bits to determine if a pixel is painted(1) or not(0).</li>
<li>Mirror the pixels vertically.</li>
<li>Scale image proportionally to requested width.</li>
</ul>
<div class="fragment"><div class="line"> 0111 0011 1101 1100</div><div class="line">^ ^</div><div class="line">+---------+---------&gt;</div><div class="line"> | |</div><div class="line">foreground color |</div><div class="line"> pixel matrix</div></div><!-- fragment --><p>Implemented in <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/src/sigil.cpp">sigil.cpp</a> </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>