#include "arc/math/rectangle.h" //VERY TEMP // #include void ARC_Rect_CenterOn(ARC_Rect *rect, ARC_Rect *bounds){ rect->x = ((bounds->x + bounds->w) / 2) - (rect->w / 2); rect->y = ((bounds->y + bounds->h) / 2) - (rect->h / 2); } void ARC_FRect_CenterOn(ARC_FRect *rect, ARC_FRect *bounds){ rect->x = ((bounds->x + bounds->w) / 2.0f) - (rect->w / 2.0f); rect->y = ((bounds->y + bounds->h) / 2.0f) - (rect->h / 2.0f); } ARC_Rect ARC_FRect_CastToRect(ARC_FRect *rect){ return (ARC_Rect){ .x = (int32_t)rect->x, .y = (int32_t)rect->y, .w = (int32_t)rect->w, .h = (int32_t)rect->h, }; } int32_t ARC_Rect_Intersects(ARC_Rect *rect1, ARC_Rect *rect2){ if(rect1->x <= rect2->x + rect2->w && rect1->x + rect1->w >= rect2->x && rect1->y <= rect2->y + rect2->h && rect1->y + rect1->h >= rect2->y){ return 1; } return 0; } int32_t ARC_Rect_LineIntersects(ARC_Rect *rect, int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2){ //TODO: Replace soon // return SDL_IntersectRectAndLine((SDL_Rect *) rect, x1, y1, x2, y2); return 1; }