pico-sdl
Loading...
Searching...
No Matches
Utils

Utilities for users. More...

Macros

#define pico_assert(x)
 Asserts condition and shows SDL error on failure.

Functions

Pico_Dim pico_dim (Pico_Pct pct)
 Returns a size relative to the screen size.
Pico_Dim pico_dim_ext (Pico_Pct pct, Pico_Dim d)
 Returns a size relative to the given rectangle's size.
int pico_pos_vs_rect (Pico_Pos pt, Pico_Rect r)
 Checks if a point is inside a rectangle. Assumes that both primitives use the same anchor.
int pico_pos_vs_rect_ext (Pico_Pos pt, Pico_Rect r, Pico_Anchor ap, Pico_Anchor ar)
 Checks if a point is inside a rectangle.
Pico_Pos pico_pos (Pico_Pct pct)
 Returns a coordinate relative to the screen rectangle.
Pico_Pos pico_pos_ext (Pico_Pct pct, Pico_Rect r, Pico_Anchor anc)
 Returns a coordinate relative to the given rectangle's position.
int pico_rect_vs_rect (Pico_Rect r1, Pico_Rect r2)
 Checks if two rectangles overlap. Assumes that both rectangles use the same anchor.
int pico_rect_vs_rect_ext (Pico_Rect r1, Pico_Rect r2, Pico_Anchor a2, Pico_Anchor a1)
 Checks if two rectangles with different anchors overlap.

Detailed Description

Utilities for users.

Macro Definition Documentation

◆ pico_assert

#define pico_assert ( x)
Value:
if (!(x)) { fprintf(stderr,"%s\n",SDL_GetError()); assert(0 && "SDL ERROR"); }

Asserts condition and shows SDL error on failure.

Parameters
xcondition to assert

Function Documentation

◆ pico_dim()

Pico_Dim pico_dim ( Pico_Pct pct)

Returns a size relative to the screen size.

Parameters
pctpercentage (may be out of [0,100])
See also
pico_dim_ext

◆ pico_dim_ext()

Pico_Dim pico_dim_ext ( Pico_Pct pct,
Pico_Dim d )

Returns a size relative to the given rectangle's size.

Parameters
pctpercentage (may be out of [0,100])
dimthe reference rectangle
See also
pico_dim

◆ pico_pos()

Pico_Pos pico_pos ( Pico_Pct pct)

Returns a coordinate relative to the screen rectangle.

Parameters
pctpercentage (may be out of [0,100])
See also
pico_pos_ext

◆ pico_pos_ext()

Pico_Pos pico_pos_ext ( Pico_Pct pct,
Pico_Rect r,
Pico_Anchor anc )

Returns a coordinate relative to the given rectangle's position.

Parameters
pctpercentage (may be out of [0,100])
rthe reference rectangle
ancanchor for r
See also
pico_pos

◆ pico_pos_vs_rect()

int pico_pos_vs_rect ( Pico_Pos pt,
Pico_Rect r )

Checks if a point is inside a rectangle. Assumes that both primitives use the same anchor.

Parameters
ptpoint
rrectangle
Returns
1 if pt is inside r, or 0 otherwise

◆ pico_pos_vs_rect_ext()

int pico_pos_vs_rect_ext ( Pico_Pos pt,
Pico_Rect r,
Pico_Anchor ap,
Pico_Anchor ar )

Checks if a point is inside a rectangle.

Parameters
ptpoint
rrectangle
apanchor for pt
aranchor for r
Returns
1 if pt is inside r, or 0 otherwise

◆ pico_rect_vs_rect()

int pico_rect_vs_rect ( Pico_Rect r1,
Pico_Rect r2 )

Checks if two rectangles overlap. Assumes that both rectangles use the same anchor.

Parameters
r1rectangle 1
r2rectangle 2
Returns
1 if r1 and r2 overlap, or 0 otherwise
See also
pico_rect_vs_rect_ext

◆ pico_rect_vs_rect_ext()

int pico_rect_vs_rect_ext ( Pico_Rect r1,
Pico_Rect r2,
Pico_Anchor a2,
Pico_Anchor a1 )

Checks if two rectangles with different anchors overlap.

Parameters
r1rectangle 1
r2rectangle 2
a1anchor for r1
a2anchor for r2
Returns
1 if r1 and r2 overlap, or 0 otherwise
See also
pico_pos_vs_rect