Rename a few things and replace floor with int truncate

This commit is contained in:
Nic Barker 2025-05-22 11:55:14 +12:00
parent 179ea4bffc
commit ea7cfcf210
2 changed files with 7 additions and 8 deletions

View file

@ -31,7 +31,7 @@ int main() {
while (true) {
Clay_RenderCommandArray renderCommands = ClayVideoDemo_CreateLayout(&demoData);
Clay_Console_Render(renderCommands, width, height, columnWidth);
Clay_Terminal_Render(renderCommands, width, height, columnWidth);
fflush(stdout);
sleep(1);

View file

@ -2,7 +2,6 @@
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#ifdef CLAY_OVERFLOW_TRAP
#include "signal.h"
@ -29,7 +28,7 @@ static inline void Console_DrawRectangle(int x0, int y0, int width, int height,
}
Console_MoveCursor(x, y);
// TODO there are only two colors actually drawn, the background and white
// TODO this should be replaced by a better logarithmic scale if we're doing black and white
if (average > 0.75) {
printf("");
} else if (average > 0.5) {
@ -73,7 +72,7 @@ Console_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void
return textSize;
}
void Clay_Console_Render(Clay_RenderCommandArray renderCommands, int width, int height, int columnWidth) {
void Clay_Terminal_Render(Clay_RenderCommandArray renderCommands, int width, int height, int columnWidth) {
printf("\033[H\033[J"); // Clear
const Clay_BoundingBox fullWindow = {
@ -88,10 +87,10 @@ void Clay_Console_Render(Clay_RenderCommandArray renderCommands, int width, int
for (int j = 0; j < renderCommands.length; j++) {
Clay_RenderCommand *renderCommand = Clay_RenderCommandArray_Get(&renderCommands, j);
Clay_BoundingBox boundingBox = (Clay_BoundingBox) {
.x = floorf((renderCommand->boundingBox.x / columnWidth) + 0.5),
.y = floorf((renderCommand->boundingBox.y / columnWidth) + 0.5),
.width = floorf((renderCommand->boundingBox.width / columnWidth) + 0.5),
.height = floorf((renderCommand->boundingBox.height / columnWidth) + 0.5),
.x = (int)((renderCommand->boundingBox.x / columnWidth) + 0.5),
.y = (int)((renderCommand->boundingBox.y / columnWidth) + 0.5),
.width = (int)((renderCommand->boundingBox.width / columnWidth) + 0.5),
.height = (int)((renderCommand->boundingBox.height / columnWidth) + 0.5),
};
switch (renderCommand->commandType) {
case CLAY_RENDER_COMMAND_TYPE_TEXT: {