Commit 5e203ca7 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

color class cleanups

parent 21c2acf5
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -44,9 +44,7 @@ Color Color::fromRGB(double red, double green, double blue) {
  return Color({ red, green, blue, 1.0 });
}

Color::Color() {
  memset(components_, 0, sizeof(components_));
}
Color::Color() : components_{0, 0, 0, 0} {}

Color::Color(
    const std::initializer_list<double>& components) {
@@ -130,9 +128,9 @@ bool Color::parseHexShort(const std::string& str) {
    return false;
  }

  components_[0] = std::stoi(str.substr(1, 1), nullptr, 16) / 16.0f;
  components_[1] = std::stoi(str.substr(2, 1), nullptr, 16) / 16.0f;
  components_[2] = std::stoi(str.substr(3, 1), nullptr, 16) / 16.0f;
  components_[0] = std::stoi(str.substr(1, 1), nullptr, 16) / 15.0f;
  components_[1] = std::stoi(str.substr(2, 1), nullptr, 16) / 15.0f;
  components_[2] = std::stoi(str.substr(3, 1), nullptr, 16) / 15.0f;
  components_[3] = 1.0f;
  return true;
}
+2 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <iostream>
#include <array>
#include <vector>
#include <string>

@@ -64,7 +65,7 @@ public:
  std::string to_hex_str() const;

protected:
  double components_[kMaxComponents];
  std::array<double, kMaxComponents> components_;
};

std::ostream& operator <<(std::ostream& os, const Color& c);