graphene.rect
Module for Rect class
class Rect
Types 1
classRect : gobject.boxed.Boxed
The location and size of a rectangle region.
The width and height of a #graphene_rect_t can be negative; for instance, a #graphene_rect_t with an origin of 0, 0 and a size of 10, 10 is equivalent to a #graphene_rect_t with an origin of 10, 10 and a size of -10, -10.
Application code can normalize rectangles using graphene.rect.Rect.normalize; this function will ensure that the width and height of a rectangle are positive values. All functions taking a #graphene_rect_t as an argument will internally operate on a normalized copy; all functions returning a #graphene_rect_t will always return a normalized rectangle.
Methods
graphene.point.Point origin() @propertyGet `origin` field. Returns: the coordinates of the origin of the rectanglevoid origin(graphene.point.Point propval) @propertySet `origin` field. Params: propval = the coordinates of the origin of the rectanglevoid size(graphene.size.Size propval) @propertySet `size` field. Params: propval = the size of the rectanglebool containsPoint(graphene.point.Point p)Checks whether a #graphene_rect_t contains the given coordinates.bool containsRect(graphene.rect.Rect b)Checks whether a #graphene_rect_t fully contains the given rectangle.bool equal(graphene.rect.Rect b)Checks whether the two given rectangle are equal.void expand(graphene.point.Point p, out graphene.rect.Rect res)Expands a #graphene_rect_t to contain the given #graphene_point_t.float getArea()Compute the area of given normalized rectangle. Returns: the area of the normalized rectanglevoid getBottomLeft(out graphene.point.Point p)Retrieves the coordinates of the bottom-left corner of the given rectangle.void getBottomRight(out graphene.point.Point p)Retrieves the coordinates of the bottom-right corner of the given rectangle.void getCenter(out graphene.point.Point p)Retrieves the coordinates of the center of the given rectangle.float getHeight()Retrieves the normalized height of the given rectangle. Returns: the normalized height of the rectanglevoid getTopLeft(out graphene.point.Point p)Retrieves the coordinates of the top-left corner of the given rectangle.void getTopRight(out graphene.point.Point p)Retrieves the coordinates of the top-right corner of the given rectangle.void getVertices(ref graphene.vec2.Vec2[] vertices)Computes the four vertices of a #graphene_rect_t.float getWidth()Retrieves the normalized width of the given rectangle. Returns: the normalized width of the rectanglefloat getX()Retrieves the normalized X coordinate of the origin of the given rectangle. Returns: the normalized X coordinate of the rectanglefloat getY()Retrieves the normalized Y coordinate of the origin of the given rectangle. Returns: the normalized Y coordinate of the rectanglegraphene.rect.Rect init_(float x, float y, float width, float height)Initializes the given #graphene_rect_t with the given values.graphene.rect.Rect initFromRect(graphene.rect.Rect src)Initializes `r` using the given src rectangle.graphene.rect.Rect inset(float dX, float dY)Changes the given rectangle to be smaller, or larger depending on the given inset parameters.void insetR(float dX, float dY, out graphene.rect.Rect res)Changes the given rectangle to be smaller, or larger depending on the given inset parameters.void interpolate(graphene.rect.Rect b, double factor, out graphene.rect.Rect res)Linearly interpolates the origin and size of the two given rectangles.bool intersection(graphene.rect.Rect b, out graphene.rect.Rect res)Computes the intersection of the two given rectangles.graphene.rect.Rect normalize()Normalizes the passed rectangle.void normalizeR(out graphene.rect.Rect res)Normalizes the passed rectangle.graphene.rect.Rect offset(float dX, float dY)Offsets the origin by d_x and d_y.void offsetR(float dX, float dY, out graphene.rect.Rect res)Offsets the origin of the given rectangle by d_x and d_y.void round(out graphene.rect.Rect res)Rounds the origin and size of the given rectangle to their nearest integer values; the rounding is guaranteed to be large enough to have an area bigger or equal to the original rectangle, but might...void roundExtents(out graphene.rect.Rect res)Rounds the origin of the given rectangle to its nearest integer value and and recompute the size so that the rectangle is large enough to contain all the conrners of the original rectangle.graphene.rect.Rect roundToPixel()Rounds the origin and the size of the given rectangle to their nearest integer values; the rounding is guaranteed to be large enough to contain the original rectangle. Returns: the pixel-aligned re...void scale(float sH, float sV, out graphene.rect.Rect res)Scales the size and origin of a rectangle horizontaly by s_h, and vertically by s_v. The result `r`es is normalized.void union_(graphene.rect.Rect b, out graphene.rect.Rect res)Computes the union of the two given rectangles.graphene.rect.Rect alloc()Allocates a new #graphene_rect_t.graphene.rect.Rect zero()Returns a degenerate rectangle with origin fixed at (0, 0) and a size of 0, 0. Returns: a fixed rectangleConstructors
this(graphene.point.Point origin = graphene.point.Point.init, graphene.size.Size size = graphene.size.Size.init)Create a `rect.Rect` boxed type. Params: origin = the coordinates of the origin of the rectangle size = the size of the rectangle