mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Adiciona comentários em Color
This commit is contained in:
parent
ac70a3c71f
commit
869703d814
@ -5,6 +5,7 @@
|
|||||||
#include "packedvalue.hpp"
|
#include "packedvalue.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
//Represents a four-component color using red, green, blue, and alpha data.
|
||||||
struct Color : public IPackedVector, public IPackedVectorT<Uint> {
|
struct Color : public IPackedVector, public IPackedVectorT<Uint> {
|
||||||
constexpr Color() = default;
|
constexpr Color() = default;
|
||||||
|
|
||||||
@ -33,10 +34,13 @@ namespace xna {
|
|||||||
|
|
||||||
virtual void PackFromVector4(Vector4 const& vector) override;
|
virtual void PackFromVector4(Vector4 const& vector) override;
|
||||||
|
|
||||||
|
//Converts a non-premultipled alpha color to a color that contains premultiplied alpha.
|
||||||
static Color FromNonPremultiplied(Vector4 const& vector);
|
static Color FromNonPremultiplied(Vector4 const& vector);
|
||||||
|
|
||||||
|
//Converts a non-premultipled alpha color to a color that contains premultiplied alpha.
|
||||||
static Color FromNonPremultiplied(Int r, Int g, Int b, Int a);
|
static Color FromNonPremultiplied(Int r, Int g, Int b, Int a);
|
||||||
|
|
||||||
|
//Gets a three-component vector representation for this object.
|
||||||
constexpr Vector3 ToVector3() const {
|
constexpr Vector3 ToVector3() const {
|
||||||
Vector3 vector3;
|
Vector3 vector3;
|
||||||
const auto byteMax = static_cast<Uint>(ByteMaxValue);
|
const auto byteMax = static_cast<Uint>(ByteMaxValue);
|
||||||
@ -46,6 +50,7 @@ namespace xna {
|
|||||||
return vector3;
|
return vector3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets a four-component vector representation for this object.
|
||||||
constexpr virtual Vector4 ToVector4() const override {
|
constexpr virtual Vector4 ToVector4() const override {
|
||||||
Vector4 vector4;
|
Vector4 vector4;
|
||||||
const auto byteMax = static_cast<Uint>(ByteMaxValue);
|
const auto byteMax = static_cast<Uint>(ByteMaxValue);
|
||||||
@ -56,48 +61,60 @@ namespace xna {
|
|||||||
return vector4;
|
return vector4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the red component value of this Color.
|
||||||
constexpr Byte R() const {
|
constexpr Byte R() const {
|
||||||
return static_cast<Byte>(_packedValue);
|
return static_cast<Byte>(_packedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the red component value of this Color.
|
||||||
constexpr void R(Byte value) {
|
constexpr void R(Byte value) {
|
||||||
_packedValue = _packedValue & (UintMaxValue - 255) | static_cast<Uint>(value);
|
_packedValue = _packedValue & (UintMaxValue - 255) | static_cast<Uint>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the green component value of this Color.
|
||||||
constexpr Byte G() const {
|
constexpr Byte G() const {
|
||||||
return static_cast<Byte>(_packedValue >> 8);
|
return static_cast<Byte>(_packedValue >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the green component value of this Color.
|
||||||
constexpr void G(Byte value) {
|
constexpr void G(Byte value) {
|
||||||
_packedValue = (static_cast<Int>(_packedValue) & -65281 | static_cast<Int>(value) << 8);
|
_packedValue = (static_cast<Int>(_packedValue) & -65281 | static_cast<Int>(value) << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the blue component value of this Color.
|
||||||
constexpr Byte B() const {
|
constexpr Byte B() const {
|
||||||
return static_cast<Byte>(_packedValue >> 16);
|
return static_cast<Byte>(_packedValue >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the blue component value of this Color.
|
||||||
constexpr void B(Byte value) {
|
constexpr void B(Byte value) {
|
||||||
_packedValue = (static_cast<Int>(_packedValue) & -16711681 | static_cast<Int>(value) << 16);
|
_packedValue = (static_cast<Int>(_packedValue) & -16711681 | static_cast<Int>(value) << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the alpha component value.
|
||||||
constexpr Byte A() const {
|
constexpr Byte A() const {
|
||||||
return static_cast<Byte>(_packedValue >> 24);
|
return static_cast<Byte>(_packedValue >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the alpha component value.
|
||||||
constexpr void A(Byte value) {
|
constexpr void A(Byte value) {
|
||||||
_packedValue = (static_cast<Int>(_packedValue) & 16777215 | static_cast<Int>(value) << 24);
|
_packedValue = (static_cast<Int>(_packedValue) & 16777215 | static_cast<Int>(value) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the current color as a packed value.
|
||||||
virtual constexpr Uint PackedValue() const override {
|
virtual constexpr Uint PackedValue() const override {
|
||||||
return _packedValue;
|
return _packedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets the current color as a packed value.
|
||||||
virtual constexpr void PackedValue(Uint const& value) override {
|
virtual constexpr void PackedValue(Uint const& value) override {
|
||||||
_packedValue = value;
|
_packedValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Linearly interpolate a color.
|
||||||
static Color Lerp(Color const& value1, Color const& value2, float amount);
|
static Color Lerp(Color const& value1, Color const& value2, float amount);
|
||||||
|
|
||||||
|
//Multiply each color component by the scale factor.
|
||||||
static constexpr Color Multiply(Color const& value, float scale) {
|
static constexpr Color Multiply(Color const& value, float scale) {
|
||||||
const Uint r = value.R();
|
const Uint r = value.R();
|
||||||
const Uint g = value.G();
|
const Uint g = value.G();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user