24 #ifndef _LV_RECTANGLE_H
25 #define _LV_RECTANGLE_H
34 #include <libvisual/lv_math.h>
52 : x (0), y (0), width (0), height (0)
63 Rect (
int x_,
int y_,
int width_,
int height_)
64 : x (x_), y (y_), width (width_), height (height_)
73 Rect (
int width_,
int height_)
74 : x (0), y (0), width (width_), height (height_)
85 void set (
int x_,
int y_,
int width_,
int height_)
87 x = x_; y = y_; width = width_; height = height_;
98 return ( width <= 0 || height <= 0 );
109 bool contains (
int x_,
int y_)
const
111 return ( x_ >= x && x_ <= x + width && y_ >= y && y_ <= y + height );
122 bool contains (
Rect const& r)
const;
131 bool intersects (
Rect const& r)
const;
159 void normalize_to (
Rect const& r)
179 void denormalize_point (
float fx,
float fy, int32_t& x_, int32_t& y_)
const
181 fx = clamp (fx, 0.0f, 1.0f);
182 fy = clamp (fx, 0.0f, 1.0f);
185 y_ = y + fy * height;
200 void denormalize_points (
float const* fxlist,
float const* fylist, int32_t* xlist, int32_t* ylist,
unsigned int size)
const;
216 void denormalize_point_neg (
float fx,
float fy, int32_t& x_, int32_t& y_)
const
218 fx = clamp (fx, -1.0f, 1.0f) * 0.5f + 0.5f;
219 fy = clamp (fy, -1.0f, 1.0f) * 0.5f + 0.5f;
222 y_ = y + fy * height;
237 void denormalize_points_neg (
float const* fxlist,
float const* fylist, int32_t* xlist, int32_t* ylist,
unsigned int size)
const;
248 struct _VisRectangle;
253 LV_API
VisRectangle *visual_rectangle_new (
int x,
int y,
int width,
int height);
258 LV_API
void visual_rectangle_set (
VisRectangle *rect,
int x,
int y,
int width,
int height);
263 LV_API
void visual_rectangle_set_x (
VisRectangle *rect,
int x);
265 LV_API
void visual_rectangle_set_y (
VisRectangle *rect,
int y);
267 LV_API
void visual_rectangle_set_width (
VisRectangle *rect,
int width);
268 LV_API
int visual_rectangle_get_width (
VisRectangle *rect);
269 LV_API
void visual_rectangle_set_height (
VisRectangle *rect,
int height);
270 LV_API
int visual_rectangle_get_height (
VisRectangle *rect);
272 LV_API
int visual_rectangle_is_empty (
VisRectangle *rect);
274 LV_API
int visual_rectangle_contains_point (
VisRectangle *rect,
int x,
int y);
278 LV_API
void visual_rectangle_normalize (
VisRectangle *rect);
281 LV_API
void visual_rectangle_denormalize_point (
VisRectangle *rect,
float fx,
float fy, int32_t *x, int32_t *y);
282 LV_API
void visual_rectangle_denormalize_points (
VisRectangle *rect,
const float *fxlist,
const float *fylist, int32_t *xlist, int32_t *ylist,
unsigned int size);
284 LV_API
void visual_rectangle_denormalize_point_neg (
VisRectangle *rect,
float fx,
float fy, int32_t *x, int32_t *y);
285 LV_API
void visual_rectangle_denormalize_points_neg (
VisRectangle *rect,
const float *fxlist,
const float *fylist, int32_t *xlist, int32_t *ylist,
unsigned int size);