2018-12-25 18:33:19 +01:00
|
|
|
/* This file is part of identiconpp.
|
|
|
|
* Public Domain / CC-0
|
2018-12-26 06:42:00 +01:00
|
|
|
*
|
2019-07-30 12:48:11 +02:00
|
|
|
* Compile with g++ $(pkg-config --libs --cflags identiconpp)
|
2018-12-25 18:33:19 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
2019-01-03 08:17:33 +01:00
|
|
|
#include <vector>
|
2019-01-03 10:07:46 +01:00
|
|
|
#include "identiconpp.hpp"
|
2018-12-26 06:30:05 +01:00
|
|
|
#include <Magick++/Image.h>
|
2018-12-25 18:33:19 +01:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-01-03 08:17:33 +01:00
|
|
|
// sha256(test@example.com)
|
|
|
|
std::string digest = "973dfe463ec85785f5f95af5ba3906ee"
|
|
|
|
"db2d931c24e69824a89ea65dba4e813b";
|
|
|
|
const std::vector<std::string> colors =
|
|
|
|
{
|
|
|
|
"800000ff",
|
|
|
|
"008000ff",
|
|
|
|
"000080ff",
|
|
|
|
"808000ff",
|
|
|
|
"008080ff",
|
|
|
|
"800080ff"
|
|
|
|
};
|
2018-12-26 06:30:05 +01:00
|
|
|
Magick::Image img;
|
|
|
|
|
2018-12-25 18:33:19 +01:00
|
|
|
if (argc > 1)
|
|
|
|
{
|
2018-12-26 06:30:05 +01:00
|
|
|
digest = argv[1];
|
2018-12-25 18:33:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-01-03 08:17:33 +01:00
|
|
|
Identiconpp identicon(4, 4, Identiconpp::algorithm::ltr_symmetric,
|
|
|
|
"ffffffff", colors, { 20, 20 });
|
|
|
|
img = identicon.generate(digest , 200);
|
|
|
|
img.write("identicon1.png");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Identiconpp identicon(5, 5, Identiconpp::algorithm::sigil,
|
|
|
|
"00000080", colors);
|
|
|
|
img = identicon.generate(digest , 200);
|
|
|
|
img.write("identicon2.png");
|
2018-12-26 04:36:58 +01:00
|
|
|
}
|
2018-12-26 06:30:05 +01:00
|
|
|
|
2018-12-27 05:21:40 +01:00
|
|
|
{
|
|
|
|
Identiconpp identicon(5, 5, Identiconpp::algorithm::ltr_asymmetric,
|
2019-01-03 08:17:33 +01:00
|
|
|
"000000ff", colors);
|
|
|
|
img = identicon.generate(digest , 200);
|
|
|
|
img.write("identicon3.png");
|
2018-12-27 05:21:40 +01:00
|
|
|
}
|
|
|
|
|
2018-12-26 22:16:11 +01:00
|
|
|
{
|
2019-01-03 08:17:33 +01:00
|
|
|
Identiconpp identicon(6, 4, Identiconpp::algorithm::ltr_symmetric,
|
|
|
|
"000000c0", colors, { 10, 10 });
|
|
|
|
img = identicon.generate(digest , 200);
|
|
|
|
img.write("identicon4.png");
|
2018-12-26 22:16:11 +01:00
|
|
|
}
|
2018-12-26 06:30:05 +01:00
|
|
|
|
2018-12-25 18:33:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|