Add a Rect object
This commit is contained in:
parent
87b3ca0efc
commit
6d253aab10
2 changed files with 28 additions and 0 deletions
20
src/basics.c
20
src/basics.c
|
@ -92,3 +92,23 @@ vector_normalize(Vector3 v)
|
|||
float inverse_length = 1 / sqrt(length2);
|
||||
return vector_init(v.x * inverse_length, v.y * inverse_length, v.z * inverse_length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Rects
|
||||
*/
|
||||
|
||||
/*
|
||||
* rect_init --
|
||||
*
|
||||
* Create a new Rect given x, y coordinates, height, and width.
|
||||
*/
|
||||
Rect
|
||||
rect_init(float x, float y, float w, float h)
|
||||
{
|
||||
Rect r;
|
||||
r.x = x;
|
||||
r.y = y;
|
||||
r.h = h;
|
||||
r.w = w;
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -26,4 +26,12 @@ float vector_length(Vector3 v);
|
|||
Vector3 vector_normalize(Vector3 v);
|
||||
|
||||
|
||||
typedef struct {
|
||||
float x, y;
|
||||
float w, h;
|
||||
} Rect;
|
||||
|
||||
Rect rect_init(float x, float y, float h, float w);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue