mirror of
https://github.com/nicbarker/clay.git
synced 2025-09-18 04:26:18 +00:00
[Renderers/SDL3] Fix border position calculated incorrectly (#446)
This commit is contained in:
parent
ff7917798c
commit
4a91cac1b2
|
@ -185,11 +185,11 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
|
||||||
if (config->width.left > 0) {
|
if (config->width.left > 0) {
|
||||||
const float starting_y = rect.y + clampedRadii.topLeft;
|
const float starting_y = rect.y + clampedRadii.topLeft;
|
||||||
const float length = rect.h - clampedRadii.topLeft - clampedRadii.bottomLeft;
|
const float length = rect.h - clampedRadii.topLeft - clampedRadii.bottomLeft;
|
||||||
SDL_FRect line = { rect.x, starting_y, config->width.left, length };
|
SDL_FRect line = { rect.x - 1, starting_y, config->width.left, length };
|
||||||
SDL_RenderFillRect(rendererData->renderer, &line);
|
SDL_RenderFillRect(rendererData->renderer, &line);
|
||||||
}
|
}
|
||||||
if (config->width.right > 0) {
|
if (config->width.right > 0) {
|
||||||
const float starting_x = rect.x + rect.w - (float)config->width.right;
|
const float starting_x = rect.x + rect.w - (float)config->width.right + 1;
|
||||||
const float starting_y = rect.y + clampedRadii.topRight;
|
const float starting_y = rect.y + clampedRadii.topRight;
|
||||||
const float length = rect.h - clampedRadii.topRight - clampedRadii.bottomRight;
|
const float length = rect.h - clampedRadii.topRight - clampedRadii.bottomRight;
|
||||||
SDL_FRect line = { starting_x, starting_y, config->width.right, length };
|
SDL_FRect line = { starting_x, starting_y, config->width.right, length };
|
||||||
|
@ -198,12 +198,12 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
|
||||||
if (config->width.top > 0) {
|
if (config->width.top > 0) {
|
||||||
const float starting_x = rect.x + clampedRadii.topLeft;
|
const float starting_x = rect.x + clampedRadii.topLeft;
|
||||||
const float length = rect.w - clampedRadii.topLeft - clampedRadii.topRight;
|
const float length = rect.w - clampedRadii.topLeft - clampedRadii.topRight;
|
||||||
SDL_FRect line = { starting_x, rect.y, length, config->width.top };
|
SDL_FRect line = { starting_x, rect.y - 1, length, config->width.top };
|
||||||
SDL_RenderFillRect(rendererData->renderer, &line);
|
SDL_RenderFillRect(rendererData->renderer, &line);
|
||||||
}
|
}
|
||||||
if (config->width.bottom > 0) {
|
if (config->width.bottom > 0) {
|
||||||
const float starting_x = rect.x + clampedRadii.bottomLeft;
|
const float starting_x = rect.x + clampedRadii.bottomLeft;
|
||||||
const float starting_y = rect.y + rect.h - (float)config->width.bottom;
|
const float starting_y = rect.y + rect.h - (float)config->width.bottom + 1;
|
||||||
const float length = rect.w - clampedRadii.bottomLeft - clampedRadii.bottomRight;
|
const float length = rect.w - clampedRadii.bottomLeft - clampedRadii.bottomRight;
|
||||||
SDL_FRect line = { starting_x, starting_y, length, config->width.bottom };
|
SDL_FRect line = { starting_x, starting_y, length, config->width.bottom };
|
||||||
SDL_SetRenderDrawColor(rendererData->renderer, config->color.r, config->color.g, config->color.b, config->color.a);
|
SDL_SetRenderDrawColor(rendererData->renderer, config->color.r, config->color.g, config->color.b, config->color.a);
|
||||||
|
@ -212,25 +212,25 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
|
||||||
//corners
|
//corners
|
||||||
if (config->cornerRadius.topLeft > 0) {
|
if (config->cornerRadius.topLeft > 0) {
|
||||||
const float centerX = rect.x + clampedRadii.topLeft -1;
|
const float centerX = rect.x + clampedRadii.topLeft -1;
|
||||||
const float centerY = rect.y + clampedRadii.topLeft;
|
const float centerY = rect.y + clampedRadii.topLeft - 1;
|
||||||
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.topLeft,
|
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.topLeft,
|
||||||
180.0f, 270.0f, config->width.top, config->color);
|
180.0f, 270.0f, config->width.top, config->color);
|
||||||
}
|
}
|
||||||
if (config->cornerRadius.topRight > 0) {
|
if (config->cornerRadius.topRight > 0) {
|
||||||
const float centerX = rect.x + rect.w - clampedRadii.topRight -1;
|
const float centerX = rect.x + rect.w - clampedRadii.topRight;
|
||||||
const float centerY = rect.y + clampedRadii.topRight;
|
const float centerY = rect.y + clampedRadii.topRight - 1;
|
||||||
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.topRight,
|
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.topRight,
|
||||||
270.0f, 360.0f, config->width.top, config->color);
|
270.0f, 360.0f, config->width.top, config->color);
|
||||||
}
|
}
|
||||||
if (config->cornerRadius.bottomLeft > 0) {
|
if (config->cornerRadius.bottomLeft > 0) {
|
||||||
const float centerX = rect.x + clampedRadii.bottomLeft -1;
|
const float centerX = rect.x + clampedRadii.bottomLeft -1;
|
||||||
const float centerY = rect.y + rect.h - clampedRadii.bottomLeft -1;
|
const float centerY = rect.y + rect.h - clampedRadii.bottomLeft;
|
||||||
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.bottomLeft,
|
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.bottomLeft,
|
||||||
90.0f, 180.0f, config->width.bottom, config->color);
|
90.0f, 180.0f, config->width.bottom, config->color);
|
||||||
}
|
}
|
||||||
if (config->cornerRadius.bottomRight > 0) {
|
if (config->cornerRadius.bottomRight > 0) {
|
||||||
const float centerX = rect.x + rect.w - clampedRadii.bottomRight -1; //TODO: why need to -1 in all calculations???
|
const float centerX = rect.x + rect.w - clampedRadii.bottomRight;
|
||||||
const float centerY = rect.y + rect.h - clampedRadii.bottomRight -1;
|
const float centerY = rect.y + rect.h - clampedRadii.bottomRight;
|
||||||
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.bottomRight,
|
SDL_Clay_RenderArc(rendererData, (SDL_FPoint){centerX, centerY}, clampedRadii.bottomRight,
|
||||||
0.0f, 90.0f, config->width.bottom, config->color);
|
0.0f, 90.0f, config->width.bottom, config->color);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue