class

Cairo::Region

Inherits Reference / Object

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

Constructors

new(region : LibCairo::PRegionT)
Source
new(rectangle : RectangleInt)

Allocates a new region object containing rectangle.

Source
new(rects : Array(RectangleInt))

Allocates a new region object containing the union of all given rects.

###Parameters

  • rects an array of count rectangles
Source
new

Allocates a new empty region object.

Source

Instance methods

==(other : Region) : Bool

Compares whether region is equivalent to other.

###Parameters

  • *other a Region object

###Returns true if both regions contained the same coverage, false if it is not or any region is in an error status.

Source
contains?(x : Int32, y : Int32) : Bool

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.

Source
contains?(rectangle : RectangleInt) : RegionOverlap

Checks whether rectangle is inside, outside or partially contained in region.

###Parameters

  • rectangle a RectangleInt

###Returns

  • RegionOverlap::In if rectangle is entirely inside region
  • RegionOverlap::Out if rectangle is entirely outside region
  • RegionOVerlap::Part if rectangle is partially inside and partially outside region
Source
contains?(p : Point) : Bool
Source
dup

Allocates a new region object copying the area from original.

Source
empty?

Checks whether region is empty.

###Returns true if region is empty, false if it isn't.

Source
extents

Gets the bounding rectangle of region as a RectangleInt.

###Parameters

  • extents rectangle into which to store the extents
Source
finalize

Destroys a Region object created with Region#initialize, Region#dup, or Region#initialize(rectangle).

Source
intersect(other : Region)

Computes the intersection of self with other and places the result in self.

###Parameters

  • other another Region

##Raises StatusException with status of Status::NoMemory.

Source
intersect(rectangle : RectangleInt)

Computes the intersection of self with rectangle and places the result in self.

###Parameters

  • rectangle a RectangleInt

###Raises StatusException with status of Status::NoMemory.

Source
num_rectangles

Returns the number of rectangles contained in region.

###Returns The number of rectangles contained in region.

Source
rectangle(nth : Int32) : RectangleInt

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.

Source
reference

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.

Source
status

Checks whether an error has previous occurred for this region object.

###Returns Status::Success or Status::NoMemory

Source
subtract(other : Region)

Subtracts other from self and places the result in self.

###Parameters

  • other another Region

###Raises StatusException with status of Status::NoMemory.

Source
subtract(rectangle : RectangleInt)

Subtracts rectangle from self and places the result in self.

###Parameters

  • rectangle a RectangleInt

###Raises StatusException with status of Status::NoMemory.

Source
to_unsafe
Source
translate(dx : Int32, dy : Int32)

Translates region by (dx, dy).

###Parameters

  • dx Amount to translate in the x direction
  • dy Amount to translate in the y direction
Source
translate(d : Point)
Source
union(other : Region)

Computes the union of self with other and places the result in self.

###Parameters

  • other another Region

###Raises StatusException with status of Status::NoMemory.

Source
union(rectangle : RectangleInt)

Computes the union of self with rectangle and places the result in self.

###Parameters

  • rectangle a RectangleInt

###Raises StatusException with status of Status::NoMemory.

Source
xor(other : Region)

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.

Source
xor_rectangle(rectangle : RectangleInt)

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.

Source