Numworks Epsilon
1.4.1
Graphing Calculator Operating System
color.cpp
Go to the documentation of this file.
1
#include <
quiz.h
>
2
#include <
kandinsky.h
>
3
#include <
assert.h
>
4
5
QUIZ_CASE
(kandinsky_color_rgb) {
6
assert
(
sizeof
(
KDColor
) == 2);
// We really want KDColor to be packed
7
8
assert
(
KDColor::RGB24
(0xFF0000) == 0xF800);
9
assert
(
KDColor::RGB24
(0x00FF00) == 0x07E0);
10
assert
(
KDColor::RGB24
(0x0000FF) == 0x1F);
11
/* R = 0x12 = 0b 0001 0010. 5 most important bits are 00010.
12
* G = 0x34 = 0b 0011 0100. 6 most important bits are 001101.
13
* B = 0x56 = 0b 0101 0110. 5 most important bits are 01010.
14
* KDColor = 0b 00010 001101 01010
15
* = 0b 0001 0001 1010 1010
16
* = 0x 1 1 A A */
17
assert
(
KDColor::RGB24
(0x123456) == 0x11AA);
18
}
19
20
QUIZ_CASE
(kandinsky_color_blend) {
21
KDColor
midGray =
KDColor::RGB24
(0x7F7F7F);
22
KDColor
res =
KDColor::blend
(
KDColorWhite
,
KDColorBlack
, 0xFF);
23
assert
(res ==
KDColorWhite
);
24
assert
(
KDColor::blend
(
KDColorWhite
,
KDColorBlack
, 0) ==
KDColorBlack
);
25
assert
(
KDColor::blend
(
KDColorWhite
,
KDColorBlack
, 0x7F) == midGray);
26
}
assert
#define assert(e)
Definition:
assert.h:9
QUIZ_CASE
QUIZ_CASE(kandinsky_color_rgb)
Definition:
color.cpp:5
assert.h
KDColorWhite
constexpr KDColor KDColorWhite
Definition:
color.h:42
KDColorBlack
constexpr KDColor KDColorBlack
Definition:
color.h:41
quiz.h
KDColor
Definition:
color.h:6
kandinsky.h
KDColor::RGB24
static constexpr KDColor RGB24(uint32_t rgb)
Definition:
color.h:13
KDColor::blend
static KDColor blend(KDColor first, KDColor second, uint8_t alpha)
Definition:
color.cpp:3
epsilon
kandinsky
test
color.cpp
Generated by
1.8.14