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:

intersect?
#t if the line segment intersects with the rect, otherwise #f
x1-new
integer x1 of the new line segment
y1-new
integer y1 of the new line segment
x2-new
integer x2 of the new line segment
y2-new
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.