Dawn/src/dawn/display/draw/drawtext.c

28 lines
640 B
C

/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "drawtext.h"
#include "assert/assert.h"
#include "util/math.h"
void drawText(
const char_t *text,
const size_t len,
const uint16_t x,
const uint16_t y,
const uint8_t color
) {
if(len == 0) return;
size_t rLen = mathMin(len, strlen(text));
assertTrue(x + rLen <= FRAME_WIDTH, "Text is too long.");
assertTrue(y < FRAME_HEIGHT, "Text is too low.");
uint16_t i = y * FRAME_WIDTH + x;
memcpy(&FRAME_BUFFER[i], text, rLen);
memset(&FRAME_COLOR[i], color, rLen);
}