chickadee » sdl2 » intersect-rect-and-line

intersect-rect-and-line rect x1 y1 x2 y2procedure

Calculates the intersection between rect and the line segment described by x1, y1, x2, and y2. See SDL_IntersectRectAndLine.

rect must be an sdl2:rect. x1, y1, x2, and y2 should be integers.

This procedure returns multiple values:

#t if the line segment intersects with the rect, otherwise #f
integer x1 of the new line segment
integer y1 of the new line segment
integer x2 of the new line segment
integer y2 of the new line segment

If the line segment does not intersect the rect, then intersect? will be #f, and x1-new, y1-new, x2-new, and y2-new will be the same as the original arguments.