Merge branch 'develop'
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2019-09-27 07:38:11 +02:00
commit 4d9dc6d8a7
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
4 changed files with 100 additions and 88 deletions

View File

@ -1,4 +1,4 @@
:coc_contact: tastytea@tastytea.de :contact-coc: tastytea@tastytea.de
== Code of Conduct == Code of Conduct
@ -32,7 +32,7 @@ Examples of unacceptable behavior by participants include:
=== Enforcement === Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at {coc_contact}. reported by contacting the project team at {contact-coc}.
All complaints will be reviewed and investigated and will result in a response All complaints will be reviewed and investigated and will result in a response
that is deemed necessary and appropriate to the circumstances. The project team that is deemed necessary and appropriate to the circumstances. The project team

View File

@ -1,9 +1,13 @@
:project: identiconpp :project: identiconpp
:patch_contact: tastytea@tastytea.de :uri-base: https://schlomp.space/tastytea/{project}
:uri-coc: {uri-base}/src/branch/master/CODE_OF_CONDUCT.adoc
:contact-email: tastytea@tastytea.de
:contact-xmpp: {contact-email}
:contact-fediverse: https://likeable.space/users/tastytea
== How to contribute == How to contribute
Read the link:CODE_OF_CONDUCT.adoc[Code of Conduct]. Read the link:{uri-coc}[Code of Conduct].
=== Reporting bugs or suggesting enhancements === Reporting bugs or suggesting enhancements
@ -12,15 +16,14 @@ https://schlomp.space/tastytea/{project}/issues[perform a search] to see if the
problem has already been reported. If it has, add a comment to the existing problem has already been reported. If it has, add a comment to the existing
issue instead of opening a new one. Same for enhancements. issue instead of opening a new one. Same for enhancements.
You can also contact me via mailto:tastytea@tastytea.de[E-Mail], You can also contact me via mailto:{contact-email}[E-Mail],
link:xmpp:tastytea@tastytea.de[XMPP] or the link:xmpp:{contact-xmpp}[XMPP] or the {contact-fediverse}[Fediverse] if you
https://likeable.space/users/tastytea[Fediverse] if you don't want to open an don't want to open an account.
account.
=== Pull requests === Pull requests
Please use similar coding conventions as the rest of the project. The basic rule Please use similar coding conventions as the rest of the project. The basic rule
to remember is to write code in the same style as the existing/surrounding code. to remember is to write code in the same style as the existing/surrounding code.
You can also send me your patches via email, to {patch_contact} (ideally using You can also send me your patches via mailto:{contact-email}[E-Mail], ideally
`git format-patch` or `git send-email`). using `git format-patch` or `git send-email`.

View File

@ -1,45 +1,63 @@
**identiconpp** is a library to generate identicons for C++. = identiconpp
:toc: preamble
:project: identiconpp
:uri-base: https://schlomp.space/tastytea/{project}
:uri-branch-master: {uri-base}/src/branch/master
:uri-reference-base: https://doc.schlomp.space/{project}
:uri-images-base: {uri-reference-base}
:uri-sigil: https://github.com/cupcake/sigil/
:uri-pydenticon: https://github.com/azaghal/pydenticon/
:uri-overlay: https://schlomp.space/tastytea/overlay
:uri-pgpkey: https://tastytea.de/tastytea_autosign.asc
:uri-gcc: https://gcc.gnu.org/
:uri-clang: https://clang.llvm.org/
:uri-cmake: https://cmake.org/
:uri-imagemagick: https://www.imagemagick.org/
:uri-asciidoc: http://asciidoc.org/
:uri-catch: https://github.com/catchorg/Catch2
*identiconpp* is a library to generate identicons for C++.
You get the images as `Magick::Image`. This allows you to make all kinds of You get the images as `Magick::Image`. This allows you to make all kinds of
modifications. modifications.
![](https://doc.schlomp.space/identiconpp/identicon1.png .Used algorithms, left to right: 4x4 ltr_symmetric, 20px padding; 5x5 sigil; 5x5 ltr_asymmetric; 6x4 ltr_symmetric, 10px padding
"4x4 identicon, ltr_symmetric, 20px padding") ====
![](https://doc.schlomp.space/identiconpp/identicon2.png image:{uri-images-base}/identicon1.png[]
"5x5 identicon, sigil") image:{uri-images-base}/identicon2.png[]
![](https://doc.schlomp.space/identiconpp/identicon3.png image:{uri-images-base}/identicon3.png[]
"5x5 identicon, ltr_asymmetric") image:{uri-images-base}/identicon4.png[]
![](https://doc.schlomp.space/identiconpp/identicon4.png
"6x4 identicon, ltr_symmetric, 10px padding")
The example images above are generated using [example.cpp] The example images above are generated using
(https://schlomp.space/tastytea/identiconpp/src/branch/master/examples/example.cpp). link:{uri-branch-master}/examples/example.cpp[example.cpp].
====
## Features == Features
* [x] Symmetric identicons * [x] Symmetric identicons
* [x] sigil identicons * [x] sigil identicons
* [x] Asymmetric identicons * [x] Asymmetric identicons
* [x] Padding * [x] Padding
## Usage == Usage
The HTML reference can be generated with `build_doc.sh`, if doxygen is The HTML reference can be generated with `build_doc.sh`, if doxygen is
installed. It is also available at [doc.schlomp.space/identiconpp/] installed. It is also available at
(https://doc.schlomp.space/identiconpp/classIdenticonpp.html). link:{uri-reference-base}/classIdenticonpp.html[doc.schlomp.space/identiconpp/].
You need to generate hashes yourself, any hexadecimal string will do. Make sure You need to generate hashes yourself, any hexadecimal string will do. Make sure
to use a safe hashing algorithm for sensitive data (**not MD5**). You can select to use a safe hashing algorithm for sensitive data (*not MD5*). You can select
as many columns and rows as you like, but make sure you have enough entropy. 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. If something seems to be wrong, exceptions will be thrown.
The "sigil" algorithm generates the same results as The "sigil" algorithm generates the same results as link:{uri-sigil}[sigil] and
[sigil](https://github.com/cupcake/sigil/) and link:{uri-pydenticon}[pydenticon].
[pydenticon](https://github.com/azaghal/pydenticon/).
### Example === Example
``` c++ [source,c++]
----
// Compile with g++ $(pkg-config --libs --cflags identiconpp) // Compile with g++ $(pkg-config --libs --cflags identiconpp)
#include <iostream> #include <iostream>
#include <identiconpp.hpp> #include <identiconpp.hpp>
@ -55,140 +73,131 @@ int main()
std::cout << identicon.generate_base64("png", "5550", 200) << std::endl; std::cout << identicon.generate_base64("png", "5550", 200) << std::endl;
} }
``` ----
## Install == Install
### Gentoo === Gentoo
Gentoo ebuilds are available via my Gentoo ebuilds are available via my link:{uri-overlay}[repository].
[repository](https://schlomp.space/tastytea/overlay).
### Automatically generated packages === Automatically generated packages
Binary packages are generated automatically for each Binary packages are generated automatically for each
[release](https://schlomp.space/tastytea/identiconpp/releases) in the formats link:{uri-base}/releases[release] in the formats `deb` and `rpm`. They are
`deb` and `rpm`. They are signed with my [automatic signing signed with my link:{uri-pgpkey}[automatic signing key].
key](https://tastytea.de/tastytea_autosign.asc).
### From source === From source
#### Dependencies ==== Dependencies
* C++ compiler (tested: [gcc](https://gcc.gnu.org/) 6/8/9, * C++ compiler (tested: link:{uri-gcc}[gcc] 6/8/9, link:{uri-clang}[clang] 7)
[clang](https://llvm.org/) 7) * {uri-cmake}[cmake] (at least 3.6)
* [cmake](https://cmake.org/) (at least 3.6) * link:{uri-imagemagick}[imagemagick] (tested: 7.0 / 6.7)
* [imagemagick](https://www.imagemagick.org/) (tested: 7.0 / 6.7)
* Optional: * Optional:
* Tests: [Catch](https://github.com/catchorg/Catch2) (tested: 2.3 / 1.2) ** Manpage: {uri-asciidoc}[asciidoc] (tested: 8.6)
** Tests: {uri-catch}[catch] (tested: 2.5 / 1.2)
On a Debian system, install the packages: On a Debian system, install the packages:
`build-essential cmake libmagick++-dev`. `build-essential cmake libmagick++-dev`.
#### Compile ==== Compile
``` shell [source,shell]
----
mkdir build mkdir build
cd build cd build
cmake .. cmake ..
make cmake --build .
make install make install
``` ----
##### cmake options
.cmake options:
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build * `-DCMAKE_BUILD_TYPE=Debug` for a debug build
* `-DWITH_TESTS=YES` to build tests * `-DWITH_TESTS=YES` to build tests
* One of: * One of:
* `-DWITH_DEB=YES` to generate a deb-package ** `-DWITH_DEB=YES` to generate a deb-package
* `-DWITH_RPM=YES` to generate an rpm-package ** `-DWITH_RPM=YES` to generate an rpm-package
To generate a binary package, execute `make package` To generate a binary package, run `make package`.
## Contributing include::{uri-base}/raw/branch/master/CONTRIBUTING.adoc[]
See [CONTRIBUTING.adoc](https://schlomp.space/tastytea/identiconpp/src/branch/master/CONTRIBUTING.adoc) == License & Copyright
## Contact ----
See https://tastytea.de/
## License & Copyright
``` text
Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>. Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>.
License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>. License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.
This program comes with ABSOLUTELY NO WARRANTY. This is free software, This program comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions. and you are welcome to redistribute it under certain conditions.
``` ----
## Algorithms == Algorithms
### ltr_symmetric === ltr_symmetric
* Create image with width=columns, height=rows. * Create image with width=columns, height=rows.
* Set background color. * Set background color.
* Select half of the columns, or half of the columns + 1 if uneven. * Select half of the columns, or half of the columns + 1 if uneven.
* `columns / 2 + columns % 2` ** `columns / 2 + columns % 2`
* Pixels are drawn from left to right, top to bottom. * Pixels are drawn from left to right, top to bottom.
* Use bits from digest to determine if a pixel is painted(1) or not(0). * Use bits from digest to determine if a pixel is painted(1) or not(0).
* Mirror the pixels vertically. * Mirror the pixels vertically.
* Use the following bits to pick the foreground color. * Use the following bits to pick the foreground color.
* You need `floor(log2(n_colors)) + 1` bits. ** You need `floor(log2(n_colors)) + 1` bits.
* Scale image proportionally to requested width. * Scale image proportionally to requested width.
```PLAIN ----
0111 0011 1101 1100 […] 1111 0111 0101 0111 0111 0011 1101 1100 […] 1111 0111 0101 0111
^ ^ ^ ^
+----------------------------+--------------> +----------------------------+-------------->
| | | |
pixel matrix foreground color pixel matrix foreground color
``` ----
Implemented in [ltr_symmetric.cpp] Implemented in
(https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_symmetric.cpp) link:{uri-branch-master}/src/ltr_symmetric.cpp[ltr_symmetric.cpp].
### ltr_asymmetric === ltr_asymmetric
* Create image with width=columns, height=rows. * Create image with width=columns, height=rows.
* Set background color. * Set background color.
* Pixels are drawn from left to right, top to bottom. * Pixels are drawn from left to right, top to bottom.
* Use bits from digest to determine if a pixel is painted(1) or not(0). * Use bits from digest to determine if a pixel is painted(1) or not(0).
* Use the following bits to pick the foreground color. * Use the following bits to pick the foreground color.
* You need `floor(log2(n_colors)) + 1` bits. ** You need `floor(log2(n_colors)) + 1` bits.
* Scale image proportionally to requested width. * Scale image proportionally to requested width.
```PLAIN ----
0111 0011 1101 1100 […] 1111 0111 0101 0111 0111 0011 1101 1100 […] 1111 0111 0101 0111
^ ^ ^ ^
+----------------------------+--------------> +----------------------------+-------------->
| | | |
pixel matrix foreground color pixel matrix foreground color
``` ----
Implemented in [ltr_asymmetric.cpp] Implemented in
(https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_asymmetric.cpp) link:{uri-branch-master}/src/ltr_asymmetric.cpp[ltr_asymmetric.cpp].
### sigil === sigil
* Create image with width=columns, height=rows. * Create image with width=columns, height=rows.
* Set background color. * Set background color.
* Select half of the columns, or half of the columns + 1 if uneven. * Select half of the columns, or half of the columns + 1 if uneven.
* `columns / 2 + columns % 2` ** `columns / 2 + columns % 2`
* Pixels are drawn from top to bottom, left to right. * Pixels are drawn from top to bottom, left to right.
* Use the first 8 bits to pick the foreground color. * Use the first 8 bits to pick the foreground color.
* Use the following bits to determine if a pixel is painted(1) or not(0). * Use the following bits to determine if a pixel is painted(1) or not(0).
* Mirror the pixels vertically. * Mirror the pixels vertically.
* Scale image proportionally to requested width. * Scale image proportionally to requested width.
```PLAIN ----
0111 0011 1101 1100 0111 0011 1101 1100
^ ^ ^ ^
+---------+---------> +---------+--------->
| | | |
foreground color | foreground color |
pixel matrix pixel matrix
``` ----
Implemented in [sigil.cpp] Implemented in link:{uri-branch-master}/src/sigil.cpp[sigil.cpp].
(https://schlomp.space/tastytea/identiconpp/src/branch/master/src/sigil.cpp)

View File

@ -8,7 +8,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Library to generate identicons for C++ and C.") "Library to generate identicons for C++ and C.")
set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>") set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md") set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.adoc")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git" list(APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git"
"/.gitignore" "/.gitignore"
"/build/" "/build/"
@ -40,7 +40,7 @@ if (WITH_RPM)
set(CPACK_RPM_PACKAGE_LICENSE "GPL-3") set(CPACK_RPM_PACKAGE_LICENSE "GPL-3")
set(CPACK_RPM_PACKAGE_URL set(CPACK_RPM_PACKAGE_URL
"https://schlomp.space/tastytea/${CMAKE_PROJECT_NAME}") "https://schlomp.space/tastytea/${CMAKE_PROJECT_NAME}")
set(CPACK_RPM_PACKAGE_REQUIRES "libMagick++, libxdg-basedir >= 1.2.0") set(CPACK_RPM_PACKAGE_REQUIRES "libMagick++")
set(CPACK_PACKAGE_FILE_NAME set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_PACKAGE_ARCHITECTURE}") "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_PACKAGE_ARCHITECTURE}")
endif() endif()