Faker C++
Loading...
Searching...
No Matches
faker::color Namespace Reference

Functions

FAKER_CXX_EXPORT std::string_view name (Locale locale=Locale::en_US)
 Returns a random color.
 
FAKER_CXX_EXPORT std::string rgb (bool includeAlpha=false)
 Returns an RGB color.
 
FAKER_CXX_EXPORT std::string hex (HexCasing casing=HexCasing::Lower, HexPrefix prefix=HexPrefix::Hash, bool includeAlpha=false)
 Returns a hex color.
 
FAKER_CXX_EXPORT std::string hsl (bool includeAlpha=false)
 Returns an HSL color.
 
FAKER_CXX_EXPORT std::string lch (bool includeAlpha=false)
 Returns an LCH color.
 
FAKER_CXX_EXPORT std::string cmyk ()
 Return a CMYK color.
 
FAKER_CXX_EXPORT std::string lab ()
 Return a LAB color.
 
FAKER_CXX_EXPORT std::string hsb ()
 Return a HSB color.
 
FAKER_CXX_EXPORT std::string hsv ()
 Return a HSV color.
 
FAKER_CXX_EXPORT std::string hwb ()
 Return a HWB color.
 
FAKER_CXX_EXPORT std::string yuv ()
 Return a YUV color.
 
FAKER_CXX_EXPORT std::string space ()
 Returns a random color space.
 

Function Documentation

◆ cmyk()

FAKER_CXX_EXPORT std::string faker::color::cmyk ( )

Return a CMYK color.

Returns
CMYK color formatted with cmyk(X,X,X,X)
faker::color::cmyk() // "cmyk(0.72, 0.88, 0.00, 0.06)"
FAKER_CXX_EXPORT std::string cmyk()
Return a CMYK color.

◆ hex()

FAKER_CXX_EXPORT std::string faker::color::hex ( HexCasing casing = HexCasing::Lower,
HexPrefix prefix = HexPrefix::Hash,
bool includeAlpha = false )

Returns a hex color.

Parameters
casingCasing of the generated string. Defaults to `HexCasing::Lower`.
prefixPrefix for the generated string. Defaults to `HexPrefix::ZeroX`.
includeAlphaAdds an alpha value to the color. Defaults to `false`.
Returns
Hex color formatted that starts with `0x` or `#`.
faker::color::hex() // "#e3f380"
faker::color::hex(HexCasing::Upper, HexPrefix::ZeroX, true) // "0xE3F3801A"
FAKER_CXX_EXPORT std::string hex(HexCasing casing=HexCasing::Lower, HexPrefix prefix=HexPrefix::Hash, bool includeAlpha=false)
Returns a hex color.
Definition airline.h:9

◆ hsb()

FAKER_CXX_EXPORT std::string faker::color::hsb ( )

Return a HSB color.

Returns
HSB color formatted with hsb(X,X,X)
faker::color::hsb() // "hsb(37, 82, 50)"
FAKER_CXX_EXPORT std::string hsb()
Return a HSB color.

◆ hsl()

FAKER_CXX_EXPORT std::string faker::color::hsl ( bool includeAlpha = false)

Returns an HSL color.

Parameters
includeAlphaAdds an alpha value to the color (HSLA). Defaults to `false`.
Returns
HSL color formatted with hsl(X,X,X) or hsla(X,X,X,X).
faker::color::hsl() // "hsl(0, 20, 100)"
faker::color::hsl(true) // "hsla(0, 0, 100, 0.50)"
FAKER_CXX_EXPORT std::string hsl(bool includeAlpha=false)
Returns an HSL color.

◆ hsv()

FAKER_CXX_EXPORT std::string faker::color::hsv ( )

Return a HSV color.

Returns
HSV color formatted with hsv(X,X,X)
faker::color::hsv() // "hsv(21, 67, 39)"
FAKER_CXX_EXPORT std::string hsv()
Return a HSV color.

◆ hwb()

FAKER_CXX_EXPORT std::string faker::color::hwb ( )

Return a HWB color.

Returns
HWB color formatted with hwb(X,X,X)
faker::color::hwb() // "hwb(34, 67, 90)"
FAKER_CXX_EXPORT std::string hwb()
Return a HWB color.

◆ lab()

FAKER_CXX_EXPORT std::string faker::color::lab ( )

Return a LAB color.

Returns
LAB color formatted with lab(X,X,X)
faker::color::lab() // "lab(98.74, 2.18, -2.35)"
FAKER_CXX_EXPORT std::string lab()
Return a LAB color.

◆ lch()

FAKER_CXX_EXPORT std::string faker::color::lch ( bool includeAlpha = false)

Returns an LCH color.

Parameters
includeAlphaAdds an alpha value to the color (LCHA). Defaults to `false`.
Returns
LCH color formatted with lch(X,X,X) or lcha(X,X,X,X).
faker::color::lch() // "lch(0, 20, 100)"
faker::color::lch(true) // "lcha(0, 0, 100, 0.50)"
FAKER_CXX_EXPORT std::string lch(bool includeAlpha=false)
Returns an LCH color.

◆ name()

FAKER_CXX_EXPORT std::string_view faker::color::name ( Locale locale = Locale::en_US)

Returns a random color.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
Human readable color name.
faker::color::name() // "Blue"
FAKER_CXX_EXPORT std::string_view name(Locale locale=Locale::en_US)
Returns a random color.

◆ rgb()

FAKER_CXX_EXPORT std::string faker::color::rgb ( bool includeAlpha = false)

Returns an RGB color.

Parameters
includeAlphaAdds an alpha value to the color (RGBA). Defaults to `false`.
Returns
RGB color formatted with rgb(X,X,X) or rgba(X,X,X,X).
faker::color::rgb() // "rgb(67, 28, 240)"
faker::color::rgb(true) // "rgba(220, 28, 79, 0.50)"
FAKER_CXX_EXPORT std::string rgb(bool includeAlpha=false)
Returns an RGB color.

◆ space()

FAKER_CXX_EXPORT std::string faker::color::space ( )

Returns a random color space.

Returns
A color space string (e.g., "sRGB", "CMYK").
FAKER_CXX_EXPORT std::string space()
Returns a random color space.

◆ yuv()

FAKER_CXX_EXPORT std::string faker::color::yuv ( )

Return a YUV color.

Returns
YUV color formatted with yuv(X,X,X)
faker::color::yuv() // "yuv(42, 234, 109)"
FAKER_CXX_EXPORT std::string yuv()
Return a YUV color.