yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gfx::SnesColor Class Reference

SNES Color container. More...

#include <snes_color.h>

Collaboration diagram for yaze::gfx::SnesColor:

Public Member Functions

constexpr SnesColor ()
 
 SnesColor (const ImVec4 val)
 Construct from ImVec4 (0.0-1.0 range)
 
 SnesColor (const uint16_t val)
 Construct from SNES 15-bit color.
 
 SnesColor (const snes_color val)
 Construct from snes_color struct (0-255 range)
 
 SnesColor (uint8_t r, uint8_t g, uint8_t b)
 Construct from RGB byte values (0-255)
 
void set_rgb (const ImVec4 val)
 Set color from ImVec4 (0.0-1.0 range)
 
void set_snes (uint16_t val)
 Set color from SNES 15-bit format.
 
constexpr ImVec4 rgb () const
 Get RGB values (WARNING: stored as 0-255 in ImVec4)
 
constexpr snes_color rom_color () const
 Get snes_color struct (0-255 RGB)
 
constexpr uint16_t snes () const
 Get SNES 15-bit color.
 
constexpr bool is_modified () const
 
constexpr bool is_transparent () const
 
constexpr void set_transparent (bool t)
 
constexpr void set_modified (bool m)
 

Private Attributes

ImVec4 rgb_
 
uint16_t snes_
 
snes_color rom_color_
 
bool modified = false
 
bool transparent = false
 

Detailed Description

SNES Color container.

Manages SNES colors in multiple formats for editing and display.

IMPORTANT: Internal storage format

  • rgb_: ImVec4 storing RGB values in 0-255 range (NOT standard 0-1!) This is unconventional but done for performance reasons
  • snes_: SNES 15-bit BGR format (0bbbbbgggggrrrrr)
  • rom_color_: snes_color struct with 0-255 RGB values

When getting RGB for display:

  • Use rgb() to get raw values (0-255 in ImVec4 - unusual!)
  • Convert to standard ImVec4 (0-1) using: ImVec4(rgb.x/255, rgb.y/255, rgb.z/255, 1.0)
  • Or use the helper: ConvertSnesColorToImVec4() in color.cc

Definition at line 109 of file snes_color.h.

Constructor & Destructor Documentation

◆ SnesColor() [1/5]

constexpr yaze::gfx::SnesColor::SnesColor ( )
inlineconstexpr

Definition at line 111 of file snes_color.h.

◆ SnesColor() [2/5]

yaze::gfx::SnesColor::SnesColor ( const ImVec4  val)
inlineexplicit

Construct from ImVec4 (0.0-1.0 range)

Parameters
valImVec4 with RGB in standard 0.0-1.0 range

Definition at line 118 of file snes_color.h.

References snes_color::blue, yaze::gfx::ConvertRgbToSnes(), snes_color::green, yaze::gfx::kColorByteMax, yaze::gfx::kColorByteMaxF, snes_color::red, rgb_, rom_color_, and snes_.

Here is the call graph for this function:

◆ SnesColor() [3/5]

yaze::gfx::SnesColor::SnesColor ( const uint16_t  val)
inlineexplicit

Construct from SNES 15-bit color.

Parameters
valSNES color in 15-bit BGR format

Definition at line 137 of file snes_color.h.

References snes_color::blue, yaze::gfx::ConvertSnesToRgb(), snes_color::green, yaze::gfx::kColorByteMaxF, snes_color::red, rgb_, and rom_color_.

Here is the call graph for this function:

◆ SnesColor() [4/5]

yaze::gfx::SnesColor::SnesColor ( const snes_color  val)
inlineexplicit

Construct from snes_color struct (0-255 range)

Parameters
valsnes_color with RGB in 0-255 range

Definition at line 148 of file snes_color.h.

References yaze::gfx::ConvertRgbToSnes().

Here is the call graph for this function:

◆ SnesColor() [5/5]

yaze::gfx::SnesColor::SnesColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

Construct from RGB byte values (0-255)

Definition at line 156 of file snes_color.h.

References snes_color::blue, yaze::gfx::ConvertRgbToSnes(), snes_color::green, yaze::gfx::kColorByteMaxF, snes_color::red, rgb_, rom_color_, and snes_.

Here is the call graph for this function:

Member Function Documentation

◆ set_rgb()

◆ set_snes()

void yaze::gfx::SnesColor::set_snes ( uint16_t  val)

◆ rgb()

constexpr ImVec4 yaze::gfx::SnesColor::rgb ( ) const
inlineconstexpr

Get RGB values (WARNING: stored as 0-255 in ImVec4)

Returns
ImVec4 with RGB in 0-255 range (unconventional!)

Definition at line 182 of file snes_color.h.

References rgb_.

Referenced by yaze::gui::ColorInfoPanel(), yaze::gui::ConvertSnesColorToImVec4(), yaze::gui::PaletteEditorWidget::DrawColorEditControls(), yaze::editor::PaletteGroupCard::DrawColorInfo(), yaze::editor::palette_utility::DrawColorInfoTooltip(), yaze::gui::PaletteEditorWidget::DrawPaletteAnalysis(), yaze::editor::PaletteEditor::DrawQuickAccessCard(), yaze::editor::PaletteEditor::DrawQuickAccessTab(), yaze::gfx::Bitmap::FindColorIndex(), yaze::gui::PaletteColorButton(), yaze::test::TEST(), yaze::test::TEST(), yaze::gfx::anonymous_namespace{palette_manager_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{palette_manager_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), yaze::gfx::anonymous_namespace{snes_color_test.cc}::TEST_F(), and yaze::gfx::ToFloatArray().

◆ rom_color()

constexpr snes_color yaze::gfx::SnesColor::rom_color ( ) const
inlineconstexpr

Get snes_color struct (0-255 RGB)

Definition at line 187 of file snes_color.h.

References rom_color_.

◆ snes()

◆ is_modified()

constexpr bool yaze::gfx::SnesColor::is_modified ( ) const
inlineconstexpr

◆ is_transparent()

constexpr bool yaze::gfx::SnesColor::is_transparent ( ) const
inlineconstexpr

Definition at line 195 of file snes_color.h.

References transparent.

◆ set_transparent()

constexpr void yaze::gfx::SnesColor::set_transparent ( bool  t)
inlineconstexpr

Definition at line 196 of file snes_color.h.

References transparent.

◆ set_modified()

constexpr void yaze::gfx::SnesColor::set_modified ( bool  m)
inlineconstexpr

Definition at line 197 of file snes_color.h.

References modified.

Referenced by yaze::Rom::SavePalette().

Member Data Documentation

◆ rgb_

ImVec4 yaze::gfx::SnesColor::rgb_
private

Definition at line 200 of file snes_color.h.

Referenced by rgb(), set_rgb(), set_snes(), SnesColor(), SnesColor(), and SnesColor().

◆ snes_

uint16_t yaze::gfx::SnesColor::snes_
private

Definition at line 201 of file snes_color.h.

Referenced by set_rgb(), set_snes(), snes(), SnesColor(), and SnesColor().

◆ rom_color_

snes_color yaze::gfx::SnesColor::rom_color_
private

Definition at line 202 of file snes_color.h.

Referenced by rom_color(), set_rgb(), set_snes(), SnesColor(), SnesColor(), and SnesColor().

◆ modified

bool yaze::gfx::SnesColor::modified = false
private

Definition at line 203 of file snes_color.h.

Referenced by is_modified(), set_modified(), set_rgb(), and set_snes().

◆ transparent

bool yaze::gfx::SnesColor::transparent = false
private

Definition at line 204 of file snes_color.h.

Referenced by is_transparent(), and set_transparent().


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