class Cairo::Region

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(region : LibCairo::PRegionT) #

[View source]
def self.new(rectangle : RectangleInt) #

Allocates a new region object containing rectangle.


[View source]
def self.new(rects : Array(RectangleInt)) #

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

###Parameters

  • rects an array of count rectangles

[View source]
def self.new #

Allocates a new empty region object.


[View source]

Instance Method Detail

def ==(other : Region) : Bool #

Compares whether region is equivalent to other.

###Parameters

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


[View source]
def 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.


[View source]
def contains?(rectangle : RectangleInt) : RegionOverlap #

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

###Parameters

###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

[View source]
def contains?(p : Point) : Bool #

[View source]
def dup : Region #

Allocates a new region object copying the area from original.


[View source]
def empty? : Bool #

Checks whether region is empty.

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


[View source]
def extents : RectangleInt #

Gets the bounding rectangle of region as a RectangleInt.

###Parameters

  • extents rectangle into which to store the extents

[View source]
def finalize #

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


[View source]
def intersect(other : Region) #

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

###Parameters

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


[View source]
def intersect(rectangle : RectangleInt) #

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

###Parameters

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


[View source]
def num_rectangles : Int32 #

Returns the number of rectangles contained in region.

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


[View source]
def 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.


[View source]
def reference : Region #

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.


[View source]
def status : Status #

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

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


[View source]
def subtract(other : Region) #

Subtracts other from self and places the result in self.

###Parameters

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


[View source]
def subtract(rectangle : RectangleInt) #

Subtracts rectangle from self and places the result in self.

###Parameters

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


[View source]
def to_unsafe : LibCairo::PRegionT #

[View source]
def 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

[View source]
def translate(d : Point) #

[View source]
def union(other : Region) #

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

###Parameters

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


[View source]
def 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.


[View source]
def 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

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


[View source]
def 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

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


[View source]