template<typename T = float, size_t Channels = 4>
color class
Contents
Represents a color.
Public types
- using value_type = T
- Alias for the type used to represent individual pixel values.
Public static variables
Constructors, destructors, conversion operators
- color()
- Construct a new color object representing (transparent) black.
- color(color const& other) defaulted
- Create a copy of the given color object.
- color(color&& other) defaulted
- Move the the given color object.
- color(T const& value)
- Construct a new color object initialised with the given value.
- color(std::initializer_list<T> values)
- Construct a new color object with given values.
- color(T const*const values)
- Construct a new color object with given values.
-
template<typename T_other>color(color_
view<T_other> const& other) - Create a copy of the given color_
view object.
Public functions
- auto operator=(color const& other) -> color& defaulted noexcept
- Copy-assigns another color.
- auto operator=(color&& other) -> color& defaulted noexcept
- Move-assigns another color.
- auto operator=(T const& value) -> color& noexcept
- Assign each channel the provided value.
- auto size() const -> size_t constexpr
- Returns the channel count.
- auto channels() const -> size_t constexpr
- Returns the channel count.
- auto data() -> T*const constexpr
- Returns the raw data pointer.
- auto data() const -> T const *const constexpr
- Returns the raw data pointer.
- auto operator[](size_t index) -> T&
- Retrieve a reference to an element of the color.
- auto operator[](size_t index) const -> T const &
- Retrieve a constant reference to an element of the color.
- auto operator+=(color const& rhs) -> color&
- Add
rhs
to this color channel-wise. - auto operator+=(T const& rhs) -> color&
- Add
rhs
to this color channel-wise. - auto operator-=(color const& rhs) -> color&
- Subtract
rhs
from this color channel-wise. - auto operator-=(T const& rhs) -> color&
- Subtract
rhs
from this color channel-wise. - auto operator*=(color const& rhs) -> color&
- Multiply this color with
rhs
channel-wise. - auto operator*=(T const& rhs) -> color&
- Multiply this color with
rhs
channel-wise. - auto operator/=(color const& rhs) -> color&
- Divide this color by
rhs
channel-wise. - auto operator/=(T const& rhs) -> color&
- Divide this color by
rhs
channel-wise.
Friends
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator==(T_other const& lhs, color const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares a color component-wise with a scalar.
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator==(color const& lhs, T_other const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares a color component-wise with a scalar.
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator!=(T_other const& lhs, color const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares a color component-wise with a scalar for inequality.
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator!=(color const& lhs, T_other const& rhs) -> std::enable_if_t<std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares a color component-wise with a scalar for inequality.
- auto operator==(color const& lhs, color const& rhs) -> bool
- Compares two colors for equality.
- auto operator!=(color const& lhs, color const& rhs) -> bool
- Compares two colors for inequality.
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator==(T_other const& lhs, color const& rhs) -> std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares two colors.
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator!=(color const& lhs, T_other const& rhs) -> std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares two colors for inequality.
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator==(color const& lhs, T_other const& rhs) -> std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares two colors.
-
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_auto operator!=(T_other const& lhs, color const& rhs) -> std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool>
view<T>>::value, int> = 0> - Compares two colors for inequality.
- auto operator+(color lhs, color const& rhs) -> color
- Add
rhs
tolhs
channel-wise. - auto operator+(color lhs, T const& rhs) -> color
- Add
rhs
tolhs
channel-wise. - auto operator-(color lhs, color const& rhs) -> color
- Subtract
rhs
fromlhs
channel-wise. - auto operator-(color lhs, T const& rhs) -> color
- Subtract
rhs
fromlhs
channel-wise. - auto operator*(color lhs, color const& rhs) -> color
- Multiply
lhs
withrhs
channel-wise. - auto operator*(color lhs, T const& rhs) -> color
- Multiply
lhs
withrhs
channel-wise. - auto operator/(color lhs, color const& rhs) -> color
- Divide
lhs
byrhs
channel-wise. - auto operator/(color lhs, T const& rhs) -> color
- Divide
lhs
byrhs
channel-wise.
Function documentation
template<typename T, size_t Channels>
spice:: color<T, Channels>:: color(T const& value)
Construct a new color object initialised with the given value.
Parameters | |
---|---|
value |
template<typename T, size_t Channels>
spice:: color<T, Channels>:: color(std::initializer_list<T> values)
Construct a new color object with given values.
Parameters | |
---|---|
values | The channel values |
template<typename T, size_t Channels>
spice:: color<T, Channels>:: color(T const*const values)
Construct a new color object with given values.
Parameters | |
---|---|
values | The channel values |
The values are assumed to be of length Channels
template<typename T, size_t Channels>
template<typename T_other>
spice:: color<T, Channels>:: color(color_ view<T_other> const& other)
Create a copy of the given color_
Parameters | |
---|---|
other | The color_ |
template<typename T, size_t Channels>
size_t spice:: color<T, Channels>:: size() const constexpr
Returns the channel count.
Returns | size_t |
---|
template<typename T, size_t Channels>
size_t spice:: color<T, Channels>:: channels() const constexpr
Returns the channel count.
Returns | size_t |
---|
template<typename T, size_t Channels>
T*const spice:: color<T, Channels>:: data() constexpr
Returns the raw data pointer.
Returns | size_t |
---|
template<typename T, size_t Channels>
T const *const spice:: color<T, Channels>:: data() const constexpr
Returns the raw data pointer.
Returns | size_t |
---|
template<typename T, size_t Channels>
T& spice:: color<T, Channels>:: operator[](size_t index)
Retrieve a reference to an element of the color.
Parameters | |
---|---|
index | |
Returns | T& |
template<typename T, size_t Channels>
T const & spice:: color<T, Channels>:: operator[](size_t index) const
Retrieve a constant reference to an element of the color.
Parameters | |
---|---|
index | |
Returns | T& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator+=(color const& rhs)
Add rhs
to this color channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator+=(T const& rhs)
Add rhs
to this color channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator-=(color const& rhs)
Subtract rhs
from this color channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator-=(T const& rhs)
Subtract rhs
from this color channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator*=(color const& rhs)
Multiply this color with rhs
channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator*=(T const& rhs)
Multiply this color with rhs
channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator/=(color const& rhs)
Divide this color by rhs
channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
color& spice:: color<T, Channels>:: operator/=(T const& rhs)
Divide this color by rhs
channel-wise.
Parameters | |
---|---|
rhs | |
Returns | color& |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator==(T_other const& lhs,
color const& rhs)
Compares a color component-wise with a scalar.
Template parameters | |
---|---|
T_other | A scalar that is comparable to the color's data type T |
Parameters | |
lhs | |
rhs | |
Returns | true if all elements of the color correspond to the scalar value, false otherwise |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator==(color const& lhs,
T_other const& rhs)
Compares a color component-wise with a scalar.
Template parameters | |
---|---|
T_other | A scalar that is comparable to the color's data type T |
Parameters | |
lhs | |
rhs | |
Returns | true if all elements of the color correspond to the scalar value, false otherwise |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator!=(T_other const& lhs,
color const& rhs)
Compares a color component-wise with a scalar for inequality.
Template parameters | |
---|---|
T_other | A scalar that is comparable to the color's data type T |
Parameters | |
lhs | |
rhs | |
Returns | true if any of the elements of the color do not correspond to the scalar value, false otherwise |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<std::is_scalar<T_other>::value, bool> operator!=(color const& lhs,
T_other const& rhs)
Compares a color component-wise with a scalar for inequality.
Template parameters | |
---|---|
T_other | A scalar that is comparable to the color's data type T |
Parameters | |
lhs | |
rhs | |
Returns | true if any of the elements of the color do not correspond to the scalar value, false otherwise |
template<typename T, size_t Channels>
bool operator==(color const& lhs,
color const& rhs)
Compares two colors for equality.
Parameters | |
---|---|
lhs | |
rhs | |
Returns | true if the two have the same number of elements with corresponding values, false otherwise |
template<typename T, size_t Channels>
bool operator!=(color const& lhs,
color const& rhs)
Compares two colors for inequality.
Parameters | |
---|---|
lhs | |
rhs | |
Returns | true if the two do not have the same number of elements or any of the values do not correspond, false otherwise |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool> operator==(T_other const& lhs,
color const& rhs)
Compares two colors.
Template parameters | |
---|---|
T_other | A type implementing the subscript operator as well as a size member function |
Parameters | |
lhs | |
rhs | |
Returns | true if the two have the same number of elements with corresponding values, false otherwise |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool> operator!=(color const& lhs,
T_other const& rhs)
Compares two colors for inequality.
Parameters | |
---|---|
lhs | |
rhs | |
Returns | true if the two do not have the same number of elements or any of the values do not correspond, false otherwise |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool> operator==(color const& lhs,
T_other const& rhs)
Compares two colors.
Template parameters | |
---|---|
T_other | A type implementing the subscript operator as well as a size member function |
Parameters | |
lhs | |
rhs | |
Returns | true if the two have the same number of elements with corresponding values, false otherwise |
template<typename T, size_t Channels>
template<typename T_other, std::enable_if_t<!std::is_same<T_other, color_ view<T>>::value, int> = 0>
std::enable_if_t<!std::is_same<color, T_other>::value && !std::is_scalar<T_other>::value, bool> operator!=(T_other const& lhs,
color const& rhs)
Compares two colors for inequality.
Parameters | |
---|---|
lhs | |
rhs | |
Returns | true if the two do not have the same number of elements or any of the values do not correspond, false otherwise |