Browse Source

Explained algorithms

tags/0.2.0
tastytea 10 months ago
parent
commit
c96df63046
Signed by: tastytea <tastytea@tastytea.de> GPG Key ID: CFC39497F1B26E07
2 changed files with 51 additions and 2 deletions
  1. +49
    -0
      README.md
  2. +2
    -2
      src/identiconpp.hpp

+ 49
- 0
README.md View File

@@ -105,3 +105,52 @@ 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,
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)

+ 2
- 2
src/identiconpp.hpp View File

@@ -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.
*

Loading…
Cancel
Save