forked from tastytea/libravatarserv
Adjust identicons to match ivatar (10x10, padding, colors, retro = identicon).
This commit is contained in:
parent
abe643bb6c
commit
fba5c64486
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.2)
|
||||
project(libravatarserv
|
||||
VERSION 0.7.1
|
||||
VERSION 0.7.2
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ The API is explained in greater detail at the
|
|||
|
||||
* OpenID
|
||||
* Because it isn't possible to store filenames with '/' in it on most filesystems.
|
||||
* The default fallbacks monsterid, wavatar, retro and robohash
|
||||
* The default fallbacks monsterid, wavatar and robohash
|
||||
* Patches welcome
|
||||
|
||||
## Usage
|
||||
|
|
|
@ -101,28 +101,33 @@ int main()
|
|||
goto not_implemented;
|
||||
}
|
||||
}
|
||||
else if (avatar.fallback.substr(0, 9) == "identicon")
|
||||
else if (avatar.fallback.substr(0, 9) == "identicon" ||
|
||||
avatar.fallback.substr(0, 5) == "retro")
|
||||
{
|
||||
try
|
||||
{
|
||||
Identiconpp identicon(4, 4, Identiconpp::algorithm::sigil,
|
||||
"ffffffff",
|
||||
{ // The 16 named colors specified in HTML 4.01
|
||||
// minus white, silver and gray.
|
||||
"000000ff", // Black
|
||||
"ff0000ff", // Red
|
||||
"800000ff", // Maroon
|
||||
"ffff00ff", // Yellow
|
||||
"808000ff", // Olive
|
||||
"00ff00ff", // lime
|
||||
"008000ff", // Green
|
||||
"00ffffff", // Aqua
|
||||
"008080ff", // Teal
|
||||
"0000ffff", // Blue
|
||||
"000080ff", // Navy
|
||||
"ff00ffff", // Fuchsia
|
||||
"800080ff", // Purple
|
||||
});
|
||||
uint8_t padwidth = avatar.size / 10;
|
||||
if (avatar.size < 60)
|
||||
{
|
||||
padwidth = 0;
|
||||
}
|
||||
else if (padwidth < 10)
|
||||
{
|
||||
padwidth = 10;
|
||||
}
|
||||
|
||||
Identiconpp identicon(10, 10, Identiconpp::algorithm::sigil,
|
||||
"#fefefe",
|
||||
{ // The same colors ivatar uses.
|
||||
"2d4fffff", // Blue
|
||||
"feb42cff", // Yellow
|
||||
"e279eaff", // Bright pink
|
||||
"1eb3fdff", // Cyan
|
||||
"E84D41ff", // Red
|
||||
"31CB73ff", // Green
|
||||
"8D45AAff" // Dark pink
|
||||
},
|
||||
{ padwidth, padwidth });
|
||||
image.image = identicon.generate(avatar.digest, avatar.size);
|
||||
image.image.magick("PNG");
|
||||
image::write(image);
|
||||
|
|
Loading…
Reference in New Issue