resonance 1.0.1
Loading...
Searching...
No Matches
Tools::CreditsAvatar Namespace Reference

Generator of the credits avatar header. More...

Functions

std::optional< std::vector< std::uint8_t > > fetchAvatar (const std::string &user, int size, const std::string &magick)
 Fetch a GitHub avatar over HTTPS and convert it to RGBA texels with ImageMagick.
std::string composeCreditsHeader (const std::string &text, int size, const std::optional< std::vector< std::uint8_t > > &texels)
 Compose the credits avatar header.

Detailed Description

Generator of the credits avatar header.

Function Documentation

◆ fetchAvatar()

std::optional< std::vector< std::uint8_t > > Tools::CreditsAvatar::fetchAvatar ( const std::string & user,
int size,
const std::string & magick )

Fetch a GitHub avatar over HTTPS and convert it to RGBA texels with ImageMagick.

Alpha is on the GS scale, where 0x80 is opaque. Each failure logs a warning and returns no texels.

Parameters
userGitHub user name.
sizeWidth and height of the texture in pixels.
magickImageMagick command, or empty when ImageMagick is not installed.
Returns
The texels, or nothing when the avatar cannot be fetched or converted.

◆ composeCreditsHeader()

std::string Tools::CreditsAvatar::composeCreditsHeader ( const std::string & text,
int size,
const std::optional< std::vector< std::uint8_t > > & texels )

Compose the credits avatar header.

The header defines RESONANCE_CREDITS_TEXT, RESONANCE_CREDITS_AVATAR_SIZE, and RESONANCE_CREDITS_HAS_AVATAR. With texels, RESONANCE_CREDITS_HAS_AVATAR is 1 and the header also defines the texel array kCreditsAvatarTexels. Without texels, RESONANCE_CREDITS_HAS_AVATAR is 0 and the credit has no picture.

Parameters
textCredit text.
sizeWidth and height of the texture in pixels.
texelsRGBA texels, or nothing for a credit without a picture.
Returns
The header text.