SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SDL::Palette Class Reference

A set of indexed colors representing a palette. More...

Public Member Functions

constexpr Palette ()=default
 Default ctor.
 
constexpr Palette (const PaletteRaw resource)
 Constructs from PaletteParam. More...
 
constexpr Palette (const Palette &other)
 Copy constructor.
 
constexpr Palette (Palette &&other)
 Move constructor.
 
 Palette (int ncolors)
 Create a palette structure with the specified number of color entries. More...
 
 ~Palette ()
 Destructor.
 
Paletteoperator= (Palette other)
 Assignment operator.
 
constexpr PaletteRaw get () const
 Retrieves underlying PaletteRaw.
 
constexpr PaletteRaw release ()
 Retrieves underlying PaletteRaw and clear this.
 
constexpr auto operator<=> (const Palette &other) const =default
 Comparison.
 
constexpr bool operator== (std::nullptr_t _) const
 Comparison.
 
constexpr operator bool () const
 Converts to bool.
 
constexpr operator PaletteParam () const
 Converts to PaletteParam.
 
void Destroy ()
 Free a palette created with Palette.Palette(). More...
 
constexpr int GetSize () const
 Returns number of colors in the palette.
 
constexpr Color operator[] (int index) const
 Access specific pallete index.
 
void SetColors (SpanRef< const ColorRaw > colors, int firstcolor=0)
 Set a range of colors in a palette. More...
 

Static Public Member Functions

static constexpr Palette Borrow (PaletteParam resource)
 Safely borrows the from PaletteParam. More...
 

Detailed Description

Since
This struct is available since SDL 3.2.0.
See also
Palette.SetColors
Category:
Resource

Constructor & Destructor Documentation

◆ Palette() [1/2]

constexpr SDL::Palette::Palette ( const PaletteRaw  resource)
inlineexplicitconstexpr
Parameters
resourcea PaletteRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

◆ Palette() [2/2]

SDL::Palette::Palette ( int  ncolors)
inline

The palette entries are initialized to white.

Parameters
ncolorsrepresents the number of color entries in the color palette.
Postcondition
a new Palette structure on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
Palette.Destroy
Palette.SetColors
Surface.SetPalette

Member Function Documentation

◆ Borrow()

static constexpr Palette SDL::Palette::Borrow ( PaletteParam  resource)
inlinestaticconstexpr
Parameters
resourcea PaletteRaw or Palette.

This does not takes ownership!


The documentation for this class was generated from the following file: