Checkpoint
This commit is contained in:
17
color.h
17
color.h
@@ -1,24 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
constexpr uint32_t kNumColors = (1 << 16);
|
||||
#include "intmath.h"
|
||||
|
||||
struct Color {
|
||||
// 32-bit for compiler convenience, but values are 16-bit
|
||||
uint32_t r;
|
||||
uint32_t g;
|
||||
uint32_t b;
|
||||
constexpr uint32_t kNumColors = UINT16_MAX;
|
||||
|
||||
// 32-bit for compiler convenience, but values are 16-bit
|
||||
struct Color : public std::array<uint32_t, 3> {
|
||||
constexpr uint32_t Difference(const Color& other) const;
|
||||
};
|
||||
|
||||
constexpr uint32_t Color::Difference(const Color& other) const {
|
||||
return (
|
||||
((r > other.r) ? (r - other.r) : (other.r - r)) +
|
||||
((g > other.g) ? (g - other.g) : (other.g - g)) +
|
||||
((b > other.b) ? (b - other.b) : (other.b - b))
|
||||
AbsDiff(this->at(0), other.at(0)) +
|
||||
AbsDiff(this->at(1), other.at(1)) +
|
||||
AbsDiff(this->at(2), other.at(2))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user