bn::sprite_palette_ptr class

std::shared_ptr like smart pointer that retains shared ownership of a sprite color palette.

Several sprite_palette_ptr objects may own the same sprite color palette.

The sprite color palette is released when the last remaining sprite_palette_ptr owning it is destroyed.

Public static functions

static auto find(const sprite_palette_item& palette_item) -> optional<sprite_palette_ptr>
Searches for a sprite_palette_ptr which contains the given colors.
static auto create(const sprite_palette_item& palette_item) -> sprite_palette_ptr
Searches for a sprite_palette_ptr which contains the given colors. If it is not found, it creates a sprite_palette_ptr which contains them.
static auto create_new(const sprite_palette_item& palette_item) -> sprite_palette_ptr
Creates a sprite_palette_ptr which contains the given colors.
static auto create_optional(const sprite_palette_item& palette_item) -> optional<sprite_palette_ptr>
Searches for a sprite_palette_ptr which contains the given colors. If it is not found, it creates a sprite_palette_ptr which contains them.
static auto create_new_optional(const sprite_palette_item& palette_item) -> optional<sprite_palette_ptr>
Creates a sprite_palette_ptr which contains the given colors.

Constructors, destructors, conversion operators

sprite_palette_ptr(const sprite_palette_ptr& other)
Copy constructor.
sprite_palette_ptr(sprite_palette_ptr&& other) noexcept
Move constructor.
~sprite_palette_ptr()
Releases the referenced sprite color palette if no more sprite_palette_ptr objects reference to it.

Public functions

auto operator=(const sprite_palette_ptr& other) -> sprite_palette_ptr&
Copy assignment operator.
auto operator=(sprite_palette_ptr&& other) -> sprite_palette_ptr& noexcept
Move assignment operator.
auto id() const -> int
Returns the internal id.
auto colors_count() const -> int
Returns the number of colors contained in this palette.
auto colors() const -> span<const color>
Returns the colors contained in this palette.
void set_colors(const sprite_palette_item& palette_item)
Sets the colors contained in this palette.
auto bpp() const -> bpp_mode
Returns the bits per pixel of this palette.
auto inverted() const -> bool
Indicates if the colors of this palette are inverted or not.
void set_inverted(bool inverted)
Sets if the colors of this palette must be inverted or not.
auto grayscale_intensity() const -> fixed
Returns the intensity of the grayscale effect applied to the colors of this palette.
void set_grayscale_intensity(fixed intensity)
Sets the intensity of the grayscale effect applied to the colors of this palette.
auto hue_shift_intensity() const -> fixed
Returns the intensity of the hue shift effect applied to the colors of this palette.
void set_hue_shift_intensity(fixed intensity)
Sets the intensity of the hue shift effect applied to the colors of this palette.
auto fade_color() const -> color
Returns the color of the fade effect applied to the colors of this palette.
auto fade_intensity() const -> fixed
Returns the intensity of the fade effect applied to the colors of this palette.
void set_fade_color(color color)
Sets the color of the fade effect applied to the colors of this palette.
void set_fade_intensity(fixed intensity)
Sets the intensity of the fade effect applied to the colors of this palette.
void set_fade(color color, fixed intensity)
Sets the color and the intensity of the fade effect applied to the colors of this palette.
auto rotate_count() const -> int
Returns the number of colors to rotate to the right in this palette.
void set_rotate_count(int count)
Sets the number of colors to rotate to the right in this palette.
void swap(sprite_palette_ptr& other)
Exchanges the contents of this sprite_palette_ptr with those of the other one.

Friends

void swap(sprite_palette_ptr& a, sprite_palette_ptr& b)
Exchanges the contents of a sprite_palette_ptr with those of another one.
auto operator==(const sprite_palette_ptr& a, const sprite_palette_ptr& b) -> bool defaulted
Default equal operator.

Function documentation

static optional<sprite_palette_ptr> bn::sprite_palette_ptr::find(const sprite_palette_item& palette_item)

Searches for a sprite_palette_ptr which contains the given colors.

Parameters
palette_item sprite_palette_item which references the colors to search.
Returns sprite_palette_ptr which contains the referenced colors by palette_item if it has been found; bn::nullopt otherwise.

static sprite_palette_ptr bn::sprite_palette_ptr::create(const sprite_palette_item& palette_item)

Searches for a sprite_palette_ptr which contains the given colors. If it is not found, it creates a sprite_palette_ptr which contains them.

Parameters
palette_item sprite_palette_item which references the colors of the palette to search or create.
Returns The requested sprite_palette_ptr.

static sprite_palette_ptr bn::sprite_palette_ptr::create_new(const sprite_palette_item& palette_item)

Creates a sprite_palette_ptr which contains the given colors.

Parameters
palette_item sprite_palette_item which references the colors of the new palette.
Returns The requested sprite_palette_ptr.

static optional<sprite_palette_ptr> bn::sprite_palette_ptr::create_optional(const sprite_palette_item& palette_item)

Searches for a sprite_palette_ptr which contains the given colors. If it is not found, it creates a sprite_palette_ptr which contains them.

Parameters
palette_item sprite_palette_item which references the colors of the palette to search or create.
Returns The requested sprite_palette_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_palette_ptr> bn::sprite_palette_ptr::create_new_optional(const sprite_palette_item& palette_item)

Creates a sprite_palette_ptr which contains the given colors.

Parameters
palette_item sprite_palette_item which references the colors of the new palette.
Returns The requested sprite_palette_ptr if it could be allocated; bn::nullopt otherwise.

bn::sprite_palette_ptr::sprite_palette_ptr(const sprite_palette_ptr& other)

Copy constructor.

Parameters
other sprite_palette_ptr to copy.

bn::sprite_palette_ptr::sprite_palette_ptr(sprite_palette_ptr&& other) noexcept

Move constructor.

Parameters
other sprite_palette_ptr to move.

sprite_palette_ptr& bn::sprite_palette_ptr::operator=(const sprite_palette_ptr& other)

Copy assignment operator.

Parameters
other sprite_palette_ptr to copy.
Returns Reference to this.

sprite_palette_ptr& bn::sprite_palette_ptr::operator=(sprite_palette_ptr&& other) noexcept

Move assignment operator.

Parameters
other sprite_palette_ptr to move.
Returns Reference to this.

void bn::sprite_palette_ptr::set_colors(const sprite_palette_item& palette_item)

Sets the colors contained in this palette.

Parameters
palette_item sprite_palette_item which references the colors to copy to this palette.

void bn::sprite_palette_ptr::set_grayscale_intensity(fixed intensity)

Sets the intensity of the grayscale effect applied to the colors of this palette.

Parameters
intensity New intensity in the range [0..1].

void bn::sprite_palette_ptr::set_hue_shift_intensity(fixed intensity)

Sets the intensity of the hue shift effect applied to the colors of this palette.

Parameters
intensity New intensity in the range [0..1].

void bn::sprite_palette_ptr::set_fade_intensity(fixed intensity)

Sets the intensity of the fade effect applied to the colors of this palette.

Parameters
intensity New intensity in the range [0..1].

void bn::sprite_palette_ptr::set_fade(color color, fixed intensity)

Sets the color and the intensity of the fade effect applied to the colors of this palette.

Parameters
color New color.
intensity New intensity in the range [0..1].

void bn::sprite_palette_ptr::set_rotate_count(int count)

Sets the number of colors to rotate to the right in this palette.

Parameters
count Number of colors to rotate to the right in the range [2 - colors_count() .. colors_count() - 2].

void bn::sprite_palette_ptr::swap(sprite_palette_ptr& other)

Exchanges the contents of this sprite_palette_ptr with those of the other one.

Parameters
other sprite_palette_ptr to exchange the contents with.

void swap(sprite_palette_ptr& a, sprite_palette_ptr& b)

Exchanges the contents of a sprite_palette_ptr with those of another one.

Parameters
a First sprite_palette_ptr to exchange the contents with.
b Second sprite_palette_ptr to exchange the contents with.