mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
clutter/rect: Add utility function to scale the rectangle
Scale coordinates and size of the rectangle by the passed value. https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
This commit is contained in:
parent
8bc8dc66f2
commit
9d9d455bba
@ -1146,14 +1146,40 @@ clutter_rect_inset (ClutterRect *rect,
|
||||
rect->size.height = 0.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_rect_scale:
|
||||
* @rect: a #ClutterRect
|
||||
* @s_x: an horizontal scale value
|
||||
* @s_y: a vertical scale value
|
||||
*
|
||||
* Scale the rectangle coordinates and size by @s_x horizontally and
|
||||
* @s_y vertically.
|
||||
*/
|
||||
void
|
||||
clutter_rect_scale (ClutterRect *rect,
|
||||
float s_x,
|
||||
float s_y)
|
||||
{
|
||||
g_return_if_fail (rect != NULL);
|
||||
g_return_if_fail (s_x > 0.f);
|
||||
g_return_if_fail (s_y > 0.f);
|
||||
|
||||
clutter_rect_normalize_internal (rect);
|
||||
|
||||
rect->origin.x *= s_x;
|
||||
rect->origin.y *= s_y;
|
||||
rect->size.width *= s_x;
|
||||
rect->size.height *= s_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_rect_clamp_to_pixel:
|
||||
* @rect: a #ClutterRect
|
||||
*
|
||||
* Rounds the origin of @rect downwards to the nearest integer, and rounds
|
||||
* the size of @rect upwards to the nearest integer, so that @rect is
|
||||
* updated to the smallest rectangle capable of fully containing the
|
||||
* original, fractional rectangle.
|
||||
* Rounds the origin of @rect downwards to the nearest integer, and recompute the
|
||||
* the size using the @rect origin and size rounded upwards to the nearest integer,
|
||||
* so that @rect is updated to the smallest rectangle capable of fully containing
|
||||
* the original, fractional rectangle in the coordinates space.
|
||||
*
|
||||
* Since: 1.12
|
||||
*/
|
||||
|
@ -361,6 +361,10 @@ void clutter_rect_inset (ClutterRect *rect
|
||||
float d_x,
|
||||
float d_y);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_rect_scale (ClutterRect *rect,
|
||||
float s_x,
|
||||
float s_y);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_rect_clamp_to_pixel (ClutterRect *rect);
|
||||
CLUTTER_EXPORT
|
||||
float clutter_rect_get_x (ClutterRect *rect);
|
||||
|
Loading…
Reference in New Issue
Block a user