summaryrefslogtreecommitdiff
path: root/plugingui/colour.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2018-06-09 12:46:09 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2018-06-09 12:51:08 +0200
commitf602f5ffd6959f4da6de0dd61ea1b60025d12294 (patch)
tree7f06de633263c23a87d0278a93825d85fcb9c1f6 /plugingui/colour.cc
parent21554166b294470ac593a1a90c82d1b4fe75c61e (diff)
Refactor Colour.
Diffstat (limited to 'plugingui/colour.cc')
-rw-r--r--plugingui/colour.cc58
1 files changed, 10 insertions, 48 deletions
diff --git a/plugingui/colour.cc b/plugingui/colour.cc
index dff1a82..9abe7eb 100644
--- a/plugingui/colour.cc
+++ b/plugingui/colour.cc
@@ -32,79 +32,41 @@ namespace GUI {
Colour::Colour()
{
- data = new float[4];
- data[0] = data[1] = data[2] = data[3] = 1.0f;
+ data = {1.0f, 1.0f, 1.0f, 1.0f};
}
Colour::Colour(float grey, float a)
{
- data = new float[4];
-
- data[0] = data[1] = data[2] = grey;
- data[3] = a;
+ data = {grey, grey, grey, a};
}
Colour::Colour(float r, float g, float b, float a)
{
- data = new float[4];
-
- data[0] = r;
- data[1] = g;
- data[2] = b;
- data[3] = a;
+ data = {r, g, b, a};
}
Colour::Colour(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a)
: Colour(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f)
{}
-Colour::Colour(Colour&& other)
-{
- if(data)
- {
- delete[] data;
- }
-
- data = other.data;
- other.data = nullptr;
-}
-
Colour::Colour(const Colour& other)
{
- if(data)
- {
- delete[] data;
- }
-
- data = new float[4];
-
- std::memcpy(data, other.data, 4 * sizeof(float));
+ data = other.data;
}
-Colour::~Colour()
+Colour& Colour::operator=(const Colour& other)
{
- if(data)
- {
- delete[] data;
- }
+ data = other.data;
}
-Colour& Colour::operator=(const Colour& other)
+bool Colour::operator==(const Colour& other) const
{
- std::memcpy(data, other.data, 4 * sizeof(float));
- return *this;
+ return data == other.data;
}
-Colour& Colour::operator=(Colour&& other)
+bool Colour::operator!=(const Colour& other) const
{
- if(data)
- {
- delete[] data;
- }
-
- data = other.data;
- other.data = nullptr;
- return *this;
+ return !(*this == other);
}
} // GUI::