Reject colors with ambiguous alpha channel

This commit is contained in:
ISSOtm
2022-05-20 18:27:54 +02:00
committed by Eldred Habert
parent 05e36767b0
commit a5ed0292b1
3 changed files with 20 additions and 8 deletions

View File

@@ -9,6 +9,7 @@
#ifndef RGBDS_GFX_RGBA_HPP
#define RGBDS_GFX_RGBA_HPP
#include <cstdint>
#include <stdint.h>
struct Rgba {
@@ -50,12 +51,10 @@ struct Rgba {
*/
static constexpr uint16_t transparent = 0b1'00000'00000'00000;
/**
* All alpha values strictly below this will be considered transparent
*/
static constexpr uint8_t opacity_threshold = 0xF0; // TODO: adjust this
// TODO: also a transparency threshold, and error out on "middle" values
bool isTransparent() const { return alpha < opacity_threshold; }
static constexpr uint8_t transparency_threshold = 0x10;
bool isTransparent() const { return alpha < transparency_threshold; }
static constexpr uint8_t opacity_threshold = 0xF0;
bool isOpaque() const { return alpha >= opacity_threshold; }
/**
* Computes the equivalent CGB color, respects the color curve depending on options
*/