Porytiles
Loading...
Searching...
No Matches
porytiles2::SupportsTransparency Concept Reference

Concept that requires a type to support transparency checks. More...

#include <supports_transparency.hpp>

Concept definition

template<typename T>
concept porytiles2::SupportsTransparency = requires(const T &t) {
{ t.is_transparent() } -> std::convertible_to<bool>;
} || requires(const T &t) {
{ t.is_transparent(t) } -> std::convertible_to<bool>;
}
Concept that requires a type to support transparency checks.

Detailed Description

Concept that requires a type to support transparency checks.

A type satisfies this concept if it has an is_transparent() method that returns a bool value. This method can either:

  • Take no parameters (intrinsic transparency only, e.g., IndexPixel where index 0 is always transparent)
  • Take a parameter of the same type (extrinsic transparency, e.g., Rgba32 where a color can match an external transparency value)

Tile and container types use requires clauses to provide only the appropriate overload(s) based on the pixel type.

Design Invariant: Types implementing this concept should default-construct to their transparent representation. That is, T{} should produce a transparent pixel value. This enables generic code to create transparent pixels without knowing the specific pixel type (e.g., Rgba32{0,0,0,0} and IndexPixel{0} both default-construct to transparent values).

Definition at line 25 of file supports_transparency.hpp.