mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-02-06 04:12:02 -05:00
31 lines
897 B
C++
31 lines
897 B
C++
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md
|
|
|
|
#include "PixelRenderer.hpp"
|
|
#include "Context.hpp"
|
|
|
|
#include <cstring>
|
|
|
|
namespace gui::renderer
|
|
{
|
|
static ColorScheme colorScheme = ::gui::Color::defaultColorScheme;
|
|
|
|
void PixelRenderer::draw(Context *ctx, Point point, Color color)
|
|
{
|
|
const auto contextWidth = ctx->getW();
|
|
const auto position = point.y * contextWidth + point.x;
|
|
|
|
std::memset(ctx->getData() + position, colorScheme.intensity[color.intensity], 1);
|
|
}
|
|
|
|
void PixelRenderer::updateColorScheme(const std::unique_ptr<ColorScheme> &scheme)
|
|
{
|
|
colorScheme = *scheme;
|
|
}
|
|
|
|
auto PixelRenderer::getColor(const uint8_t intensity) -> uint8_t
|
|
{
|
|
return colorScheme.intensity[intensity];
|
|
}
|
|
} // namespace gui::renderer
|