Files
dali_cpp/include/color.hpp
2026-03-26 12:04:08 +08:00

31 lines
1.2 KiB
C++

#pragma once
#include <array>
#include <cstdint>
#include <vector>
// Colour conversion utilities mirroring lib/dali/color.dart.
class DaliColor {
public:
static std::array<int, 4> toIntList(double a, double r, double g, double b);
static int toInt(double a, double r, double g, double b);
static double decimalRound(int num, double idp);
static std::array<double, 3> gammaCorrection(double r, double g, double b, double gamma = 2.8);
static std::array<double, 3> rgb2xyz(double r, double g, double b);
static std::array<int, 3> xyz2rgb(double x, double y, double z);
static std::array<double, 2> xyz2xy(double x, double y, double z);
static std::array<double, 3> xy2xyz(double xVal, double yVal);
static std::array<double, 2> rgb2xy(double r, double g, double b);
static std::array<int, 3> xy2rgb(double xVal, double yVal);
static std::array<double, 3> xyz2lab(double x, double y, double z);
static std::array<double, 3> rgb2lab(double r, double g, double b);
static std::array<double, 3> lab2xyz(double l, double a, double b);
static std::array<int, 3> lab2rgb(double l, double a, double b);
private:
static double srgbToLinear(double value);
static double linearToSrgb(double value);
};