Add a Rect object

This commit is contained in:
Eryn Wells 2013-09-06 19:01:02 -07:00
parent 87b3ca0efc
commit 6d253aab10
2 changed files with 28 additions and 0 deletions

View file

@ -92,3 +92,23 @@ vector_normalize(Vector3 v)
float inverse_length = 1 / sqrt(length2); float inverse_length = 1 / sqrt(length2);
return vector_init(v.x * inverse_length, v.y * inverse_length, v.z * inverse_length); 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;
}

View file

@ -26,4 +26,12 @@ float vector_length(Vector3 v);
Vector3 vector_normalize(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 #endif