From c96df630460e84dcc89a069b76287b28b243c2a3 Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 26 Dec 2018 23:51:32 +0100 Subject: [PATCH] Explained algorithms --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++ src/identiconpp.hpp | 4 ++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb9d433..4155dec 100644 --- a/README.md +++ b/README.md @@ -105,3 +105,52 @@ License GPLv3: GNU GPL version 3 . This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. ``` + +## Algorithms + +### ltr_symmetric + +* Create image with width=columns, height=rows. +* Set background color. +* Select half of the columns, or half of the columns + 1 if uneven. + * `columns / 2 + columns % 2` +* 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). +* Mirror the pixels vertically. +* Use the following bits to pick the foreground color. +* Scale image proportionally to requested width. + +```PLAIN + 0111 0011 1101 1100 […] 1111 0111 0101 0111 +^ ^ ++----------------------------+--------------> + | | + pixel matrix foreground color +``` + +Implemented in [ltr_symmetric.cpp] +(https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_symmetric.cpp) + +### sigil + +* Create image with width=columns, height=rows. +* Set background color. +* Select half of the columns, or half of the columns + 1 if uneven. + * `columns / 2 + columns % 2` +* Pixels are drawn from top to bottom, left to right. +* 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). +* Mirror the pixels vertically. +* Scale image proportionally to requested width. + +```PLAIN + 0111 0011 1101 1100 +^ ^ ++---------+---------> + | | +foreground color | + pixel matrix +``` + +Implemented in [sigil.cpp] +(https://schlomp.space/tastytea/identiconpp/src/branch/master/src/sigil.cpp) diff --git a/src/identiconpp.hpp b/src/identiconpp.hpp index 3b55958..5b32967 100644 --- a/src/identiconpp.hpp +++ b/src/identiconpp.hpp @@ -80,7 +80,7 @@ private: /*! * @brief Generate simple identicon. * - * Use bits 0 to (columns / 2 + columns % 2) * _rows, use the + * Use bits 0 to (_columns / 2 + _columns % 2) * _rows, use the * following bits to determine foreground color. Squares are drawn * from left to right, top to bottom. * @@ -97,7 +97,7 @@ private: /*! * @brief Generate sigil identicon. * - * Use bits 9 to (columns / 2 + columns % 2) * _rows, use the first + * Use bits 9 to (_columns / 2 + _columns % 2) * _rows, use the first * 8 bits to determine foreground color. Squares are drawn from top * to bottom, left to right. *