2024-05-29 16:29:08 +10:00
|
|
|
#include <cruft/util/colour.hpp>
|
2015-04-13 18:06:08 +10:00
|
|
|
|
2024-05-29 16:29:08 +10:00
|
|
|
#include <cruft/util/tap.hpp>
|
2015-01-15 14:03:44 +11:00
|
|
|
|
2016-07-28 13:31:52 +10:00
|
|
|
|
2015-01-15 14:03:44 +11:00
|
|
|
int
|
|
|
|
main (int, char**)
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::TAP::logger tap;
|
2015-04-13 16:45:56 +10:00
|
|
|
|
2015-04-09 20:45:55 +10:00
|
|
|
// Check casting works between intergral and floating formats
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::srgba<4,float> f {1.f};
|
|
|
|
cruft::srgba<4,uint8_t> u {255};
|
2015-04-13 16:45:56 +10:00
|
|
|
tap.expect_eq (f.cast<uint8_t> (), u, "cast float to u8");
|
|
|
|
tap.expect_eq (u.cast<float> (), f, "cast u8 to float");
|
2015-04-09 20:45:55 +10:00
|
|
|
}
|
2015-04-09 20:46:55 +10:00
|
|
|
|
2021-05-12 13:26:52 +10:00
|
|
|
{
|
|
|
|
cruft::srgba3f white {1, 1, 1};
|
|
|
|
cruft::srgba3f black {0, 0, 0};
|
|
|
|
cruft::srgba3f percent_50 { 0.735359f, 0.735356f, 0.735357f };
|
|
|
|
|
|
|
|
tap.expect (max (scale_luminance (white, 1.f) - white) < 1e-5f, "unit luminance scaling for white");
|
|
|
|
tap.expect (max (scale_luminance (white, 0.f) - black) < 1e-5f, "zero luminance scaling for white");
|
|
|
|
tap.expect (max (scale_luminance (white, .5f) - percent_50) < 1e-5f, "half luminance scaling for white");
|
|
|
|
}
|
|
|
|
|
2017-05-22 13:55:21 +10:00
|
|
|
return tap.status ();
|
2015-01-15 14:03:44 +11:00
|
|
|
}
|