class Cairo::Region
- Cairo::Region
- Reference
- Object
Overview
A Region represents a set of integer-aligned rectangles.
It allows set-theoretical operations like Region#union and Region#intersect to be performed on them.
Memory management of Region is done with Region#reference and Region#finalize.
Wrapper for LibCairo::PRegionT
Defined in:
cairo/region.crConstructors
- .new(region : LibCairo::PRegionT)
-
.new(rectangle : RectangleInt)
Allocates a new region object containing rectangle.
-
.new(rects : Array(RectangleInt))
Allocates a new region object containing the union of all given rects.
-
.new
Allocates a new empty region object.
Instance Method Summary
-
#==(other : Region) : Bool
Compares whether region is equivalent to other.
-
#contains?(x : Int32, y : Int32) : Bool
Checks whether (x, y) is contained in region.
-
#contains?(rectangle : RectangleInt) : RegionOverlap
Checks whether rectangle is inside, outside or partially contained in region.
- #contains?(p : Point) : Bool
-
#dup : Region
Allocates a new region object copying the area from original.
-
#empty? : Bool
Checks whether region is empty.
-
#extents : RectangleInt
Gets the bounding rectangle of region as a
RectangleInt. -
#finalize
Destroys a
Regionobject created withRegion#initialize,Region#dup, orRegion#initialize(rectangle). -
#intersect(other : Region)
Computes the intersection of
selfwith other and places the result inself. -
#intersect(rectangle : RectangleInt)
Computes the intersection of
selfwith rectangle and places the result inself. -
#num_rectangles : Int32
Returns the number of rectangles contained in region.
-
#rectangle(nth : Int32) : RectangleInt
Stores the nth rectangle from the region in rectangle.
-
#reference : Region
Increases the reference count on region by one.
-
#status : Status
Checks whether an error has previous occurred for this region object.
-
#subtract(other : Region)
Subtracts other from
selfand places the result inself. -
#subtract(rectangle : RectangleInt)
Subtracts rectangle from
selfand places the result inself. - #to_unsafe : LibCairo::PRegionT
-
#translate(dx : Int32, dy : Int32)
Translates region by (dx, dy).
- #translate(d : Point)
-
#union(other : Region)
Computes the union of
selfwith other and places the result inself. -
#union(rectangle : RectangleInt)
Computes the union of
selfwith rectangle and places the result inself. -
#xor(other : Region)
Computes the exclusive difference of
selfwith other and places the result inself. -
#xor_rectangle(rectangle : RectangleInt)
Computes the exclusive difference of
selfwith rectangle and places the result inself.
Constructor Detail
Allocates a new region object containing the union of all given rects.
###Parameters
- rects an array of count rectangles
Instance Method Detail
Compares whether region is equivalent to other.
###Parameters
- *other a
Regionobject
###Returns
true if both regions contained the same coverage, false if it is not or any region is in an error status.
Checks whether (x, y) is contained in region.
###Parameters
- x the x coordinate of a point
- y the y coordinate of a point
###Returns
true if (x, y) is contained in region, false if it is not.
Checks whether rectangle is inside, outside or partially contained in region.
###Parameters
- rectangle a
RectangleInt
###Returns
RegionOverlap::Inif rectangle is entirely inside regionRegionOverlap::Outif rectangle is entirely outside regionRegionOVerlap::Partif rectangle is partially inside and partially outside region
Checks whether region is empty.
###Returns
true if region is empty, false if it isn't.
Gets the bounding rectangle of region as a RectangleInt.
###Parameters
- extents rectangle into which to store the extents
Destroys a Region object created with Region#initialize, Region#dup, or Region#initialize(rectangle).
Computes the intersection of self with other and places the result in self.
###Parameters
- other another
Region
##Raises
StatusException with status of Status::NoMemory.
Computes the intersection of self with rectangle and places the result in self.
###Parameters
- rectangle a
RectangleInt
###Raises
StatusException with status of Status::NoMemory.
Returns the number of rectangles contained in region.
###Returns The number of rectangles contained in region.
Stores the nth rectangle from the region in rectangle.
###Parameters
- nth a number indicating which rectangle should be returned
###Returns
The location for a RectangleInt.
Increases the reference count on region by one. This prevents region from being destroyed until a matching call
to Region#finalize is made.
###Returns
The referenced Region.
Checks whether an error has previous occurred for this region object.
###Returns
Status::Success or Status::NoMemory
Subtracts other from self and places the result in self.
###Parameters
- other another
Region
###Raises
StatusException with status of Status::NoMemory.
Subtracts rectangle from self and places the result in self.
###Parameters
- rectangle a
RectangleInt
###Raises
StatusException with status of Status::NoMemory.
Translates region by (dx, dy).
###Parameters
- dx Amount to translate in the x direction
- dy Amount to translate in the y direction
Computes the union of self with other and places the result in self.
###Parameters
- other another
Region
###Raises
StatusException with status of Status::NoMemory.
Computes the union of self with rectangle and places the result in self.
###Parameters
- rectangle a RectangleInt
###Raises
StatusException with status of Status::NoMemory.
Computes the exclusive difference of self with other and places the result in self.
That is, self will be set to contain all areas that are either in self or in other , but not in both.
###Parameters
- other another
Region
###Raises
StatusException with status of Status::NoMemory.
Computes the exclusive difference of self with rectangle and places the result in self.
That is, self will be set to contain all areas that are either in self or in rectangle, but not in both.
###Parameters
- rectangle a
RectangleInt
###Raises
StatusException with status of Status::NoMemory.