Colorf class
#include <nCine/Primitives/Colorf.h>
Four-channel normalized color with 32-bit floats per component.
Stores the red, green, blue and alpha channels as float values, with the alpha clamped to the 0-1 range. Provides array and channel-wise construction, channel-wise and scalar arithmetic, and conversion to and from the 8-bit integer Color.
Constructors, destructors, conversion operators
- Colorf() constexpr noexcept
- Default constructor, creates an opaque white color.
- Colorf(NoInitT) explicit noexcept
- Colorf(float red, float green, float blue) constexpr noexcept
- Constructs an opaque color from three channels.
- Colorf(float red, float green, float blue, float alpha) constexpr noexcept
- Constructs a color from four channels, clamping the alpha to the 0-1 range.
- Colorf(const float channels[NumChannels]) explicit noexcept
- Constructs a color from a four-channel array.
- Colorf(const Color& color) explicit noexcept
Public functions
- auto Data() const -> const float*
- Returns a pointer to the channel array.
- auto Data() -> float*
- void Set(float red, float green, float blue, float alpha) constexpr
- Sets all four channels, clamping the alpha to the 0-1 range.
- void Set(float red, float green, float blue)
- Sets the three color channels, keeping the alpha unchanged.
- void SetVec(const float channels[NumChannels])
- Sets all four channels from an array.
- void SetAlpha(float alpha)
- Sets the alpha channel.
- auto operator=(const Color& color) -> Colorf&
- Assigns from an 8-bit integer color.
- auto operator==(const Colorf& color) const -> bool
- auto operator!=(const Colorf& color) const -> bool
- auto operator+=(const Colorf& v) -> Colorf&
- auto operator-=(const Colorf& v) -> Colorf&
- auto operator*=(const Colorf& color) -> Colorf&
- auto operator*=(float scalar) -> Colorf&
- Multiplies all channels by a scalar.
- auto operator+(const Colorf& color) const -> Colorf
- auto operator-(const Colorf& color) const -> Colorf
- auto operator*(const Colorf& color) const -> Colorf
- auto operator*(float scalar) const -> Colorf
- Multiplies all channels by a scalar.
Public variables
Constants
-
static std::
int32_t NumChannels constexpr - Number of channels.
Predefined colors
Function documentation
float* nCine:: Primitives:: Colorf:: Data()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Colorf operator""_rgbf(unsigned long long value) constexpr
Float RGB color literal.
using namespace nCine::Primitives::Literals; Colorf a = 0x5eb233bb_rgbf; // R: 0x5e, G: 0xb2, B: 0x33, A: 0xff
See Colorf for more information.
Colorf operator""_rgbaf(unsigned long long value) constexpr
Float RGBA color literal.
using namespace nCine::Primitives::Literals; Colorf a = 0x5eb233bb_rgbaf; // R: 0x5e, G: 0xb2, B: 0x33, A: 0xbb
See Colorf for more information.