Top |
Functions
#define | GSK_ROUNDED_RECT_INIT() |
GskRoundedRect * | gsk_rounded_rect_init () |
GskRoundedRect * | gsk_rounded_rect_init_copy () |
GskRoundedRect * | gsk_rounded_rect_init_from_rect () |
GskRoundedRect * | gsk_rounded_rect_normalize () |
GskRoundedRect * | gsk_rounded_rect_offset () |
GskRoundedRect * | gsk_rounded_rect_shrink () |
gboolean | gsk_rounded_rect_is_rectilinear () |
gboolean | gsk_rounded_rect_contains_point () |
gboolean | gsk_rounded_rect_contains_rect () |
gboolean | gsk_rounded_rect_intersects_rect () |
Description
GskRoundedRect defines a rectangle with rounded corners, as is commonly used in drawing.
Operations on a GskRoundedRect will normalize the rectangle, to ensure that the bounds are normalized and that the corner sizes don't exceed the size of the rectangle. The algorithm used for normalizing corner sizes is described in the CSS specification.
Functions
GSK_ROUNDED_RECT_INIT()
#define GSK_ROUNDED_RECT_INIT(_x,_y,_w,_h)
Initializes a GskRoundedRect when declaring it. All corner sizes will be initialized to 0.
gsk_rounded_rect_init ()
GskRoundedRect * gsk_rounded_rect_init (GskRoundedRect *self
,const graphene_rect_t *bounds
,const graphene_size_t *top_left
,const graphene_size_t *top_right
,const graphene_size_t *bottom_right
,const graphene_size_t *bottom_left
);
Initializes the given GskRoundedRect with the given values.
This function will implicitly normalize the GskRoundedRect before returning.
Parameters
self |
The GskRoundedRect to initialize |
|
bounds |
a graphene_rect_t describing the bounds |
|
top_left |
the rounding radius of the top left corner |
|
top_right |
the rounding radius of the top right corner |
|
bottom_right |
the rounding radius of the bottom right corner |
|
bottom_left |
the rounding radius of the bottom left corner |
gsk_rounded_rect_init_copy ()
GskRoundedRect * gsk_rounded_rect_init_copy (GskRoundedRect *self
,const GskRoundedRect *src
);
Initializes self
using the given src
rectangle.
This function will not normalize the GskRoundedRect, so make sure the source is normalized.
gsk_rounded_rect_init_from_rect ()
GskRoundedRect * gsk_rounded_rect_init_from_rect (GskRoundedRect *self
,const graphene_rect_t *bounds
,float radius
);
Initializes self
to the given bounds
and sets the radius of all
four corners to radius
.
gsk_rounded_rect_normalize ()
GskRoundedRect *
gsk_rounded_rect_normalize (GskRoundedRect *self
);
Normalizes the passed rectangle.
this function will ensure that the bounds of the rectangle are normalized and ensure that the corner values are positive and the corners do not overlap.
gsk_rounded_rect_offset ()
GskRoundedRect * gsk_rounded_rect_offset (GskRoundedRect *self
,float dx
,float dy
);
Offsets the bound's origin by dx
and dy
.
The size and corners of the rectangle are unchanged.
gsk_rounded_rect_shrink ()
GskRoundedRect * gsk_rounded_rect_shrink (GskRoundedRect *self
,float top
,float right
,float bottom
,float left
);
Shrinks (or grows) the given rectangle by moving the 4 sides according to the offsets given. The corner radii will be changed in a way that tries to keep the center of the corner circle intact. This emulates CSS behavior.
This function also works for growing rectangles if you pass
negative values for the top
, right
, bottom
or left
.
Parameters
self |
The GskRoundedRect to shrink or grow |
|
top |
How far to move the top side downwards |
|
right |
How far to move the right side to the left |
|
bottom |
How far to move the bottom side upwards |
|
left |
How far to move the left side to the right |
gsk_rounded_rect_is_rectilinear ()
gboolean
gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self
);
Checks if all corners of self
are right angles and the
rectangle covers all of its bounds.
This information can be used to decide if gsk_clip_node_new()
or gsk_rounded_clip_node_new()
should be called.
gsk_rounded_rect_contains_point ()
gboolean gsk_rounded_rect_contains_point (const GskRoundedRect *self
,const graphene_point_t *point
);
Checks if the given point
is inside the rounded rectangle. This function
returns FALSE
if the point is in the rounded corner areas.
gsk_rounded_rect_contains_rect ()
gboolean gsk_rounded_rect_contains_rect (const GskRoundedRect *self
,const graphene_rect_t *rect
);
Checks if the given rect
is contained inside the rounded rectangle.
This function returns FALSE
if rect
extends into one of the rounded
corner areas.
gsk_rounded_rect_intersects_rect ()
gboolean gsk_rounded_rect_intersects_rect (const GskRoundedRect *self
,const graphene_rect_t *rect
);
Checks if part of the given rect
is contained inside the rounded rectangle.
This function returns FALSE
if rect
only extends into one of the rounded
corner areas but not into the rounded rectangle itself.
Types and Values
struct GskRoundedRect
struct GskRoundedRect { graphene_rect_t bounds; graphene_size_t corner[4]; };
A rectangular region with rounded corners.
Application code should normalize rectangles using gsk_rounded_rect_normalize()
;
this function will ensure that the bounds of the rectangle are normalized
and ensure that the corner values are positive and the corners do not overlap.
All functions taking a GskRoundedRect as an argument will internally operate on
a normalized copy; all functions returning a GskRoundedRect will always return
a normalized one.
Members
graphene_rect_t |
the bounds of the rectangle |
|
graphene_size_t |
the size of the 4 rounded corners |