Renamed: simple -> ltr_symmetric; libravatar -> sigil; identicon_type -> algorithm
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
d724317304
commit
43865a6b4e
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.2)
|
cmake_minimum_required (VERSION 3.2)
|
||||||
project(identiconpp
|
project(identiconpp
|
||||||
VERSION 0.1.2
|
VERSION 0.2.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
10
example.cpp
10
example.cpp
|
@ -20,7 +20,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Identiconpp identicon(13, 10, Identiconpp::identicon_type::simple,
|
Identiconpp identicon(5, 5, Identiconpp::algorithm::ltr_symmetric,
|
||||||
"ffffff88",
|
"ffffff88",
|
||||||
{
|
{
|
||||||
"000000ff",
|
"000000ff",
|
||||||
|
@ -31,11 +31,11 @@ int main(int argc, char *argv[])
|
||||||
"0000ffff"
|
"0000ffff"
|
||||||
});
|
});
|
||||||
img = identicon.generate(digest, 500);
|
img = identicon.generate(digest, 500);
|
||||||
img.write("identicon_example_simple.png");
|
img.write("identicon_example_ltr_symmetric.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Identiconpp identicon(5, 5, Identiconpp::identicon_type::libravatar,
|
Identiconpp identicon(5, 5, Identiconpp::algorithm::sigil,
|
||||||
"ffffffff",
|
"ffffffff",
|
||||||
{
|
{
|
||||||
"000000ff",
|
"000000ff",
|
||||||
|
@ -45,8 +45,8 @@ int main(int argc, char *argv[])
|
||||||
"00ffffff",
|
"00ffffff",
|
||||||
"0000ffff"
|
"0000ffff"
|
||||||
});
|
});
|
||||||
img = identicon.generate("5a105e8b9d40e1329780d62ea2265d8a", 500);
|
img = identicon.generate(digest, 500);
|
||||||
img.write("identicon_example_libravatar.png");
|
img.write("identicon_example_sigil.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
#include "identiconpp.hpp"
|
#include "identiconpp.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
void Identiconpp::check_entropy(const string &digest, identicon_type type)
|
void Identiconpp::check_entropy(const string &digest, algorithm type)
|
||||||
{
|
{
|
||||||
uint16_t entropy_provided;
|
uint16_t entropy_provided;
|
||||||
uint16_t entropy_required;
|
uint16_t entropy_required;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case identicon_type::simple:
|
case algorithm::ltr_symmetric:
|
||||||
{
|
{
|
||||||
// Every char is 4 bit
|
// Every char is 4 bit
|
||||||
entropy_provided = digest.length() * 4;
|
entropy_provided = digest.length() * 4;
|
||||||
|
@ -36,8 +36,7 @@ void Identiconpp::check_entropy(const string &digest, identicon_type type)
|
||||||
+ (_foreground.size() / 2 + _foreground.size() % 2);
|
+ (_foreground.size() / 2 + _foreground.size() % 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case identicon_type::libravatar:
|
case algorithm::sigil:
|
||||||
case identicon_type::sigil:
|
|
||||||
{
|
{
|
||||||
entropy_provided = digest.length() / 2 * 8;
|
entropy_provided = digest.length() / 2 * 8;
|
||||||
entropy_required = (_columns / 2 + _columns % 2) * _rows + 8;
|
entropy_required = (_columns / 2 + _columns % 2) * _rows + 8;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
Identiconpp::Identiconpp(const uint8_t rows, const uint8_t columns,
|
Identiconpp::Identiconpp(const uint8_t rows, const uint8_t columns,
|
||||||
identicon_type type,
|
algorithm type,
|
||||||
const string &background,
|
const string &background,
|
||||||
const vector<string> &foreground)
|
const vector<string> &foreground)
|
||||||
: _rows(rows)
|
: _rows(rows)
|
||||||
|
@ -48,14 +48,13 @@ Magick::Image Identiconpp::generate(const string &digest, const uint16_t width)
|
||||||
|
|
||||||
switch (_type)
|
switch (_type)
|
||||||
{
|
{
|
||||||
case identicon_type::simple:
|
case algorithm::ltr_symmetric:
|
||||||
{
|
{
|
||||||
return generate_simple(digest, width, height);
|
return generate_ltr_symmetric(digest, width, height);
|
||||||
}
|
}
|
||||||
case identicon_type::libravatar:
|
case algorithm::sigil:
|
||||||
case identicon_type::sigil:
|
|
||||||
{
|
{
|
||||||
return generate_libravatar(digest, width, height);
|
return generate_sigil(digest, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,11 @@ class Identiconpp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* @brief List of identicon types
|
* @brief List of identicon algorithms
|
||||||
*
|
|
||||||
* libravatar and sigil are synonymous.
|
|
||||||
*/
|
*/
|
||||||
enum class identicon_type
|
enum class algorithm
|
||||||
{
|
{
|
||||||
simple,
|
ltr_symmetric,
|
||||||
libravatar,
|
|
||||||
sigil
|
sigil
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,7 +56,7 @@ public:
|
||||||
* @param foreground vector of foreground colors
|
* @param foreground vector of foreground colors
|
||||||
*/
|
*/
|
||||||
explicit Identiconpp(const uint8_t rows, const uint8_t columns,
|
explicit Identiconpp(const uint8_t rows, const uint8_t columns,
|
||||||
identicon_type type = identicon_type::simple,
|
algorithm type = algorithm::ltr_symmetric,
|
||||||
const string &background = "ffffffff",
|
const string &background = "ffffffff",
|
||||||
const vector<string> &foreground = { "000000ff" } );
|
const vector<string> &foreground = { "000000ff" } );
|
||||||
|
|
||||||
|
@ -76,7 +73,7 @@ public:
|
||||||
private:
|
private:
|
||||||
const uint8_t _rows;
|
const uint8_t _rows;
|
||||||
const uint8_t _columns;
|
const uint8_t _columns;
|
||||||
const identicon_type _type;
|
const algorithm _type;
|
||||||
const string _background;
|
const string _background;
|
||||||
const vector<string> _foreground;
|
const vector<string> _foreground;
|
||||||
|
|
||||||
|
@ -93,12 +90,12 @@ private:
|
||||||
*
|
*
|
||||||
* @return The image
|
* @return The image
|
||||||
*/
|
*/
|
||||||
Magick::Image generate_simple(const string &digest,
|
Magick::Image generate_ltr_symmetric(const string &digest,
|
||||||
const uint16_t width,
|
const uint16_t width,
|
||||||
const uint16_t height);
|
const uint16_t height);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Generate libravatar-style / sigil identicon.
|
* @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
|
* 8 bits to determine foreground color. Squares are drawn from top
|
||||||
|
@ -110,9 +107,9 @@ private:
|
||||||
*
|
*
|
||||||
* @return The image
|
* @return The image
|
||||||
*/
|
*/
|
||||||
Magick::Image generate_libravatar(const string &digest,
|
Magick::Image generate_sigil(const string &digest,
|
||||||
const uint16_t width,
|
const uint16_t width,
|
||||||
const uint16_t height);
|
const uint16_t height);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Check if the digest contains enough entropy.
|
* @brief Check if the digest contains enough entropy.
|
||||||
|
@ -122,7 +119,7 @@ private:
|
||||||
* @param digest The pre-computed digest
|
* @param digest The pre-computed digest
|
||||||
* @param type The type of identicon
|
* @param type The type of identicon
|
||||||
*/
|
*/
|
||||||
void check_entropy(const string &digest, identicon_type type);
|
void check_entropy(const string &digest, algorithm type);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Determines if the n-th bit of passed digest is 1 or 0.
|
* @brief Determines if the n-th bit of passed digest is 1 or 0.
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
#include "identiconpp.hpp"
|
#include "identiconpp.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
Magick::Image Identiconpp::generate_simple(const string &digest,
|
Magick::Image Identiconpp::generate_ltr_symmetric(const string &digest,
|
||||||
const uint16_t width,
|
const uint16_t width,
|
||||||
const uint16_t height)
|
const uint16_t height)
|
||||||
{
|
{
|
||||||
Magick::Image img(Magick::Geometry(_columns, _rows),
|
Magick::Image img(Magick::Geometry(_columns, _rows),
|
||||||
Magick::Color("#" + _background));
|
Magick::Color("#" + _background));
|
|
@ -17,9 +17,9 @@
|
||||||
#include "identiconpp.hpp"
|
#include "identiconpp.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
Magick::Image Identiconpp::generate_libravatar(const string &digest,
|
Magick::Image Identiconpp::generate_sigil(const string &digest,
|
||||||
const uint16_t width,
|
const uint16_t width,
|
||||||
const uint16_t height)
|
const uint16_t height)
|
||||||
{
|
{
|
||||||
// throw "Not implemented.";
|
// throw "Not implemented.";
|
||||||
Magick::Image img(Magick::Geometry(_columns, _rows),
|
Magick::Image img(Magick::Geometry(_columns, _rows),
|
Loading…
Reference in New Issue