VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
Colors.h
1// -----------------------------------------------------------------------------
2// This file is part of VirtualC64
3//
4// Copyright (C) Dirk W. Hoffmann. www.dirkwhoffmann.de
5// This FILE is dual-licensed. You are free to choose between:
6//
7// - The GNU General Public License v3 (or any later version)
8// - The Mozilla Public License v2
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR MPL-2.0
11// -----------------------------------------------------------------------------
12
13#pragma once
14
15#include "Types.h"
16
17namespace vc64 {
18
19struct RgbColor {
20
21 double r;
22 double g;
23 double b;
24
25 RgbColor() : r(0), g(0), b(0) {}
26 RgbColor(double rv, double gv, double bv) : r(rv), g(gv), b(bv) {}
27 RgbColor(u8 rv, u8 gv, u8 bv) : r(rv / 255.0), g(gv / 255.0), b(bv / 255.0) {}
28 RgbColor(const struct YuvColor &c);
29 RgbColor(const struct GpuColor &c);
30
31 static const RgbColor black;
32 static const RgbColor white;
33 static const RgbColor red;
34 static const RgbColor green;
35 static const RgbColor blue;
36 static const RgbColor yellow;
37 static const RgbColor magenta;
38 static const RgbColor cyan;
39
40 RgbColor mix(RgbColor additive, double weight);
41 RgbColor mix(RgbColor additive, double weight1, double weight2);
42 RgbColor tint(double weight) { return mix(white, weight); }
43 RgbColor shade(double weight) { return mix(black, weight); }
44};
45
46struct YuvColor {
47
48 double y;
49 double u;
50 double v;
51
52 YuvColor() : y(0), u(0), v(0) { }
53 YuvColor(double yv, double uv, double vv) : y(yv), u(uv), v(vv) { }
54 YuvColor(u8 yv, u8 uv, u8 vv) : y(yv / 255.0), u(uv / 255.0), v(vv / 255.0) { }
55 YuvColor(const struct RgbColor &c);
56 YuvColor(const struct GpuColor &c) : YuvColor(RgbColor(c)) { }
57
58 static const YuvColor black;
59 static const YuvColor white;
60 static const YuvColor red;
61 static const YuvColor green;
62 static const YuvColor blue;
63 static const YuvColor yellow;
64 static const YuvColor magenta;
65 static const YuvColor cyan;
66};
67
68struct GpuColor {
69
70 u32 abgr;
71
72 GpuColor() : abgr(0) {}
73 GpuColor(u32 v) : abgr(v) {}
74 GpuColor(const struct RgbColor &c);
75 GpuColor(u8 r, u8 g, u8 b);
76
77 static const GpuColor black;
78 static const GpuColor white;
79 static const GpuColor red;
80 static const GpuColor green;
81 static const GpuColor blue;
82 static const GpuColor yellow;
83 static const GpuColor magenta;
84 static const GpuColor cyan;
85
86 GpuColor mix(const struct RgbColor &color, double weight);
87 GpuColor mix(const struct RgbColor &color, double weight1, double weight2);
88 GpuColor tint(double weight) { return mix(RgbColor::white, weight); }
89 GpuColor shade(double weight) { return mix(RgbColor::black, weight); }
90};
91
92}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16