mirror of
https://github.com/nicbarker/clay.git
synced 2025-09-18 20:46:17 +00:00
Rename a few things and replace floor with int truncate
This commit is contained in:
parent
179ea4bffc
commit
ea7cfcf210
|
@ -31,7 +31,7 @@ int main() {
|
||||||
while (true) {
|
while (true) {
|
||||||
Clay_RenderCommandArray renderCommands = ClayVideoDemo_CreateLayout(&demoData);
|
Clay_RenderCommandArray renderCommands = ClayVideoDemo_CreateLayout(&demoData);
|
||||||
|
|
||||||
Clay_Console_Render(renderCommands, width, height, columnWidth);
|
Clay_Terminal_Render(renderCommands, width, height, columnWidth);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
#ifdef CLAY_OVERFLOW_TRAP
|
#ifdef CLAY_OVERFLOW_TRAP
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
|
@ -29,7 +28,7 @@ static inline void Console_DrawRectangle(int x0, int y0, int width, int height,
|
||||||
}
|
}
|
||||||
|
|
||||||
Console_MoveCursor(x, y);
|
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) {
|
if (average > 0.75) {
|
||||||
printf("█");
|
printf("█");
|
||||||
} else if (average > 0.5) {
|
} else if (average > 0.5) {
|
||||||
|
@ -73,7 +72,7 @@ Console_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void
|
||||||
return textSize;
|
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
|
printf("\033[H\033[J"); // Clear
|
||||||
|
|
||||||
const Clay_BoundingBox fullWindow = {
|
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++) {
|
for (int j = 0; j < renderCommands.length; j++) {
|
||||||
Clay_RenderCommand *renderCommand = Clay_RenderCommandArray_Get(&renderCommands, j);
|
Clay_RenderCommand *renderCommand = Clay_RenderCommandArray_Get(&renderCommands, j);
|
||||||
Clay_BoundingBox boundingBox = (Clay_BoundingBox) {
|
Clay_BoundingBox boundingBox = (Clay_BoundingBox) {
|
||||||
.x = floorf((renderCommand->boundingBox.x / columnWidth) + 0.5),
|
.x = (int)((renderCommand->boundingBox.x / columnWidth) + 0.5),
|
||||||
.y = floorf((renderCommand->boundingBox.y / columnWidth) + 0.5),
|
.y = (int)((renderCommand->boundingBox.y / columnWidth) + 0.5),
|
||||||
.width = floorf((renderCommand->boundingBox.width / columnWidth) + 0.5),
|
.width = (int)((renderCommand->boundingBox.width / columnWidth) + 0.5),
|
||||||
.height = floorf((renderCommand->boundingBox.height / columnWidth) + 0.5),
|
.height = (int)((renderCommand->boundingBox.height / columnWidth) + 0.5),
|
||||||
};
|
};
|
||||||
switch (renderCommand->commandType) {
|
switch (renderCommand->commandType) {
|
||||||
case CLAY_RENDER_COMMAND_TYPE_TEXT: {
|
case CLAY_RENDER_COMMAND_TYPE_TEXT: {
|
||||||
|
|
Loading…
Reference in a new issue