Browse Source

Explained algorithms

tags/0.2.0
tastytea 6 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>.
105 105
 This program comes with ABSOLUTELY NO WARRANTY. This is free software,
106 106
 and you are welcome to redistribute it under certain conditions.
107 107
 ```
108
+
109
+## Algorithms
110
+
111
+### ltr_symmetric
112
+
113
+* Create image with width=columns, height=rows.
114
+* Set background color.
115
+* Select half of the columns, or half of the columns + 1 if uneven.
116
+  * `columns / 2 + columns % 2`
117
+* Pixels are drawn from left to right, top to bottom.
118
+* Use bits from digest to determine if a pixel is painted(1) or not(0).
119
+* Mirror the pixels vertically.
120
+* Use the following bits to pick the foreground color.
121
+* Scale image proportionally to requested width.
122
+
123
+```PLAIN
124
+ 0111 0011 1101 1100 […] 1111 0111 0101 0111
125
+^                            ^
126
++----------------------------+-------------->
127
+             |                      |
128
+        pixel matrix        foreground color
129
+```
130
+
131
+Implemented in [ltr_symmetric.cpp]
132
+(https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_symmetric.cpp)
133
+
134
+### sigil
135
+
136
+* Create image with width=columns, height=rows.
137
+* Set background color.
138
+* Select half of the columns, or half of the columns + 1 if uneven.
139
+  * `columns / 2 + columns % 2`
140
+* Pixels are drawn from top to bottom, left to right.
141
+* Use the first 8 bits to pick the foreground color.
142
+* Use the following bits to determine if a pixel is painted(1) or not(0).
143
+* Mirror the pixels vertically.
144
+* Scale image proportionally to requested width.
145
+
146
+```PLAIN
147
+ 0111 0011 1101 1100
148
+^         ^
149
++---------+--------->
150
+     |            |
151
+foreground color  |
152
+             pixel matrix
153
+```
154
+
155
+Implemented in [sigil.cpp]
156
+(https://schlomp.space/tastytea/identiconpp/src/branch/master/src/sigil.cpp)

+ 2
- 2
src/identiconpp.hpp View File

@@ -80,7 +80,7 @@ private:
80 80
     /*!
81 81
      *  @brief  Generate simple identicon.
82 82
      *
83
-     *          Use bits 0 to (columns / 2 + columns % 2) * _rows, use the
83
+     *          Use bits 0 to (_columns / 2 + _columns % 2) * _rows, use the
84 84
      *          following bits to determine foreground color. Squares are drawn
85 85
      *          from left to right, top to bottom.
86 86
      *
@@ -97,7 +97,7 @@ private:
97 97
     /*!
98 98
      *  @brief  Generate sigil identicon.
99 99
      *
100
-     *          Use bits 9 to (columns / 2 + columns % 2) * _rows, use the first
100
+     *          Use bits 9 to (_columns / 2 + _columns % 2) * _rows, use the first
101 101
      *          8 bits to determine foreground color. Squares are drawn from top
102 102
      *          to bottom, left to right.
103 103
      *

Loading…
Cancel
Save