mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Initial commit
This commit is contained in:
13
arm9/source/gui/palette/DirectPalette.cpp
Normal file
13
arm9/source/gui/palette/DirectPalette.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "common.h"
|
||||
#include "DirectPalette.h"
|
||||
|
||||
u32 DirectPalette::GetHashCode() const
|
||||
{
|
||||
u32 hashcode = 1430287;
|
||||
#pragma GCC unroll 8
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
hashcode = hashcode * 7302013 + ((u32*)_colors)[i];
|
||||
}
|
||||
return hashcode;
|
||||
}
|
||||
23
arm9/source/gui/palette/DirectPalette.h
Normal file
23
arm9/source/gui/palette/DirectPalette.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "IPalette.h"
|
||||
|
||||
/// @brief Palette of 16 specified colors.
|
||||
class alignas(4) DirectPalette : public IPalette
|
||||
{
|
||||
public:
|
||||
explicit DirectPalette(const u16* colors)
|
||||
{
|
||||
memcpy(_colors, colors, sizeof(_colors));
|
||||
}
|
||||
|
||||
void GetColors(u16* dst) const override
|
||||
{
|
||||
memcpy(dst, _colors, sizeof(_colors));
|
||||
}
|
||||
|
||||
u32 GetHashCode() const override;
|
||||
|
||||
private:
|
||||
u16 _colors[16];
|
||||
};
|
||||
14
arm9/source/gui/palette/GradientPalette.cpp
Normal file
14
arm9/source/gui/palette/GradientPalette.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "common.h"
|
||||
#include "GradientPalette.h"
|
||||
|
||||
u32 GradientPalette::GetHashCode() const
|
||||
{
|
||||
u32 hashcode = 1430287;
|
||||
hashcode = hashcode * 7302013 + _fromColor.r;
|
||||
hashcode = hashcode * 7302013 + _fromColor.g;
|
||||
hashcode = hashcode * 7302013 + _fromColor.b;
|
||||
hashcode = hashcode * 7302013 + _toColor.r;
|
||||
hashcode = hashcode * 7302013 + _toColor.g;
|
||||
hashcode = hashcode * 7302013 + _toColor.b;
|
||||
return hashcode;
|
||||
}
|
||||
23
arm9/source/gui/palette/GradientPalette.h
Normal file
23
arm9/source/gui/palette/GradientPalette.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "core/math/Rgb.h"
|
||||
#include "core/math/RgbMixer.h"
|
||||
#include "IPalette.h"
|
||||
|
||||
/// @brief Gradient palette between two colors.
|
||||
class GradientPalette : public IPalette
|
||||
{
|
||||
public:
|
||||
GradientPalette(const Rgb<8, 8, 8>& from, const Rgb<8, 8, 8>& to)
|
||||
: _fromColor(from), _toColor(to) { }
|
||||
|
||||
void GetColors(u16* dst) const override
|
||||
{
|
||||
RgbMixer::MakeGradientPalette(dst, _fromColor, _toColor);
|
||||
}
|
||||
|
||||
u32 GetHashCode() const override;
|
||||
|
||||
private:
|
||||
Rgb<8, 8, 8> _fromColor;
|
||||
Rgb<8, 8, 8> _toColor;
|
||||
};
|
||||
18
arm9/source/gui/palette/IPalette.h
Normal file
18
arm9/source/gui/palette/IPalette.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
/// @brief Interface for a color palette.
|
||||
class IPalette
|
||||
{
|
||||
public:
|
||||
virtual ~IPalette() = 0;
|
||||
|
||||
/// @brief Gets the colors of the palette.
|
||||
/// @param dst A pointer to an array the colors should be written to.
|
||||
virtual void GetColors(u16* dst) const = 0;
|
||||
|
||||
/// @brief Gets a hash that represents this color palette.
|
||||
/// @return The hash.
|
||||
virtual u32 GetHashCode() const = 0;
|
||||
};
|
||||
|
||||
inline IPalette::~IPalette() { }
|
||||
Reference in New Issue
Block a user