[studio/modlib] Add function for exporting selection color
This commit is contained in:
parent
c0479604aa
commit
a72b865dc9
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <ox/std/math.hpp>
|
||||||
#include <ox/std/types.hpp>
|
#include <ox/std/types.hpp>
|
||||||
|
|
||||||
namespace nostalgia::core {
|
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))
|
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>(g), 31) << 5)
|
||||||
| static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(b), 31) << 10)
|
| 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]]
|
[[nodiscard]]
|
||||||
|
@ -139,10 +139,7 @@ void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_model.pixelSelected(i)) {
|
if (m_model.pixelSelected(i)) {
|
||||||
auto const r = red16(color) / 2;
|
color = studio::applySelectionColor(color);
|
||||||
auto const g = (green16(color) + 20) / 2;
|
|
||||||
auto const b = (blue16(color) + 31) / 2;
|
|
||||||
color = color16(r, g, b);
|
|
||||||
}
|
}
|
||||||
setPixelBufferObject(paneSize, static_cast<unsigned>(i * VertexVboRows), fx, fy, color, vbo, ebo);
|
setPixelBufferObject(paneSize, static_cast<unsigned>(i * VertexVboRows), fx, fy, color, vbo, ebo);
|
||||||
});
|
});
|
||||||
|
17
src/olympic/studio/modlib/include/studio/color.hpp
Normal file
17
src/olympic/studio/modlib/include/studio/color.hpp
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <studio/color.hpp>
|
||||||
#include <studio/context.hpp>
|
#include <studio/context.hpp>
|
||||||
#include <studio/editor.hpp>
|
#include <studio/editor.hpp>
|
||||||
#include <studio/filedialog.hpp>
|
#include <studio/filedialog.hpp>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user