SDL_GETRECTANDLINEINTERSECTION(3)
β¨ NAME β¨
SDL_GetRectAndLineIntersection β bestie, this one calculates the intersection of a rectangle and a line segment π (it lives in the SDL3 FUNCTIONS manual, iykyk)
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_rect.h>
bool SDL_GetRectAndLineIntersection(const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2);
π DESCRIPTION π
okay so picture this: you have a line segment and you have a rectangle, and you need to know where they overlap. That's literally what this function does β it's used to clip a line segment to a rectangle. Slay. β¨
Here's the vibe check on the possible outcomes:
- A line segment that's contained entirely within the rectangle β stays unchanged. No touchy.
- A line segment that does not intersect β also stays unchanged. She's unbothered.
- A line segment that crosses the rectangle at either or both ends β gets clipped to the boundary of the rectangle, and the new coordinates get saved into
X1,Y1,X2, and/orY2as necessary. π
Like the way that the endpoints just get rewritten in place? iconic behavior tbh.
π¦ FUNCTION PARAMETERS π¦
rectβ anSDL_Rectstructure representing the rectangle to intersect. This is the box, bestie. π¦X1β a pointer to the starting X-coordinate of the line. πY1β a pointer to the starting Y-coordinate of the line. πX2β a pointer to the ending X-coordinate of the line. πY2β a pointer to the ending Y-coordinate of the line. π
π RETURN VALUE π
Returns true if there is an intersection, false otherwise. Simple as that, no cap. π«Ά
π THREAD SAFETY π
It is safe to call this function from any thread. Every thread gets to eat. periodt. π
β AVAILABILITY β
This function is available since SDL 3.2.0. If you're on something older, that's a no from her. π
Simple Directmedia Layer β SDL 3.4.18 β SDL_GetRectAn...eIntersection(3)
k bye bestie, go clip some lines πβ¨ππ¦πΈπ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms