[studio/modlib] Add function for exporting selection color

This commit is contained in:
Gary Talent 2024-05-24 22:06:48 -05:00
parent c0479604aa
commit a72b865dc9
4 changed files with 21 additions and 5 deletions

View File

@ -4,6 +4,7 @@
#pragma once
#include <ox/std/math.hpp>
#include <ox/std/types.hpp>
namespace nostalgia::core {
@ -135,7 +136,7 @@ constexpr Color16 color16(int r, int g, int b, int a = 0) noexcept {
return static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(r), 31))
| static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(g), 31) << 5)
| static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(b), 31) << 10)
| static_cast<Color16>(a << 15);
| static_cast<Color16>(a << 15);
}
[[nodiscard]]

View File

@ -139,10 +139,7 @@ void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept {
return;
}
if (m_model.pixelSelected(i)) {
auto const r = red16(color) / 2;
auto const g = (green16(color) + 20) / 2;
auto const b = (blue16(color) + 31) / 2;
color = color16(r, g, b);
color = studio::applySelectionColor(color);
}
setPixelBufferObject(paneSize, static_cast<unsigned>(i * VertexVboRows), fx, fy, color, vbo, ebo);
});

View File

@ -0,0 +1,17 @@
#pragma once
#include <nostalgia/core/color.hpp>
namespace studio {
[[nodiscard]]
constexpr nostalgia::core::Color16 applySelectionColor(
nostalgia::core::Color16 const color) noexcept {
namespace core = nostalgia::core;
auto const r = core::red16(color) / 2;
auto const g = (core::green16(color) + 20) / 2;
auto const b = (core::blue16(color) + 31) / 2;
return core::color16(r, g, b);
}
}

View File

@ -4,6 +4,7 @@
#pragma once
#include <studio/color.hpp>
#include <studio/context.hpp>
#include <studio/editor.hpp>
#include <studio/filedialog.hpp>