ARC_FObround added

This commit is contained in:
herbglitch 2023-06-25 22:14:32 -06:00
parent c3361f640c
commit 5aede928d8
7 changed files with 62 additions and 0 deletions

View file

@ -12,6 +12,8 @@ extern "C" {
void ARC_Obround_Render(ARC_Obround *obround, ARC_Renderer *renderer, ARC_Color *color); void ARC_Obround_Render(ARC_Obround *obround, ARC_Renderer *renderer, ARC_Color *color);
void ARC_FObround_Render(ARC_FObround *obround, ARC_Renderer *renderer, ARC_Color *color);
// void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color); // void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -14,6 +14,8 @@ void ARC_Rect_Render(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color);
void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color); void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color);
void ARC_FRect_Render(ARC_FRect *rect, ARC_Renderer *renderer, ARC_Color *color);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -14,6 +14,31 @@ typedef struct ARC_Obround {
int32_t h; int32_t h;
} ARC_Obround; } ARC_Obround;
typedef struct ARC_FObround {
float x;
float y;
float r;
float h;
} ARC_FObround;
/**
* @brief casts Obround to FObround
*
* @param obround ARC_Obround to be casted
*
* @return ARC_FObround
*/
ARC_FObround ARC_Obround_CastToFObround(ARC_Obround *obround);
/**
* @brief casts FObround to Obround
*
* @param obround ARC_FObround to be casted
*
* @return ARC_Obround
*/
ARC_Obround ARC_FObround_CastToObround(ARC_FObround *obround);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -43,4 +43,9 @@ void ARC_Obround_Render(ARC_Obround *obround, ARC_Renderer *renderer, ARC_Color
} }
} }
void ARC_FObround_Render(ARC_FObround *obround, ARC_Renderer *renderer, ARC_Color *color){
ARC_Obround casted = ARC_FObround_CastToObround(obround);
ARC_Obround_Render(&casted, renderer, color);
}
#endif // ARC_SDL #endif // ARC_SDL

View file

@ -13,4 +13,9 @@ void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *colo
SDL_RenderFillRect((SDL_Renderer *)renderer, (SDL_Rect *) rect); SDL_RenderFillRect((SDL_Renderer *)renderer, (SDL_Rect *) rect);
} }
void ARC_FRect_Render(ARC_FRect *rect, ARC_Renderer *renderer, ARC_Color *color){
ARC_Rect casted = ARC_FRect_CastToRect(rect);
ARC_Rect_Render(&casted, renderer, color);
}
#endif // ARC_SDL #endif // ARC_SDL

View file

@ -0,0 +1,19 @@
#include "arc/math/obround.h"
ARC_FObround ARC_Obround_CastToFObround(ARC_Obround *obround){
return (ARC_FObround){
.x = (float)obround->x,
.y = (float)obround->y,
.r = (float)obround->r,
.h = (float)obround->h
};
}
ARC_Obround ARC_FObround_CastToObround(ARC_FObround *obround){
return (ARC_Obround){
.x = (int32_t)obround->x,
.y = (int32_t)obround->y,
.r = (int32_t)obround->r,
.h = (int32_t)obround->h
};
}

View file

@ -3,6 +3,10 @@
void ARC_Vector2_Normalize(ARC_Vector2 *vector){ void ARC_Vector2_Normalize(ARC_Vector2 *vector){
float length = sqrtf((vector->x * vector->x) + (vector->y * vector->y)); float length = sqrtf((vector->x * vector->x) + (vector->y * vector->y));
if(length == 0){
return;
}
vector->x /= length; vector->x /= length;
vector->y /= length; vector->y /= length;
} }