Region
public final class Region
Region
describes the set of pixels used to clip Canvas
. Region
is compact,
efficiently storing a single integer rectangle, or a run length encoded array
of rectangles. Region
may reduce the current Canvas
clip, or may be drawn as
one or more integer rectangles. Region
iterator returns the scan lines or
rectangles contained by it, optionally intersecting a bounding rectangle.
-
Constructs an empty
Region
.Region
is set to empty bounds at (0, 0) with zero width and height.Declaration
Swift
public init()
-
Constructs a copy of an existing region. Copy constructor makes two regions identical by value. Internally, region and the returned result share pointer values. The underlying
Rect
array is copied when modified. Creating aRegion
copy is very efficient and never allocates memory.Region
are always copied by value from the interface; the underlying shared pointers are not exposed.Declaration
Swift
public init(region: Region)
Parameters
region
Region
to copy by value -
Undocumented
Declaration
Swift
public convenience init(rect: IRect)
-
Undocumented
Declaration
Swift
public convenience init(path: Path)
-
Constructs a rectangular
Region
matching the bounds of rect. If rect is empty, constructs empty and returns false.Declaration
Swift
@discardableResult public func setRect(_ rect: IRect) -> Bool
Parameters
rect
bounds of constructed
Region
Return Value
true if rect is not empty
-
Constructs
Region
to match outline of path within clip. Returns false if constructedRegion
is empty. ConstructedRegion
draws the same pixels as path through clip when anti-aliasing is disabled.Declaration
Swift
public func setPath(_ path: Path, clip: Region)
Parameters
path
Path
providing outlineclip
Region
containing pathReturn Value
true if constructed
Region
is not empty -
Set this region to the area described by the path, clipped to the current region.
Declaration
Swift
public func setPath(_ path: Path)
Parameters
path
The replacement path.
Return Value
true if constructed
Region
is not empty -
Replaces
Region
with the result ofRegion
op rect. Returns true if replacedRegion
is not empty.Declaration
Swift
public func op(rect: IRect, op: RegionOperation) -> Bool
Parameters
rect
IRect
operandop
operator to apply
Return Value
false if result is empty
-
Replaces
Region
with the result ofRegion
op rgn. Returns true if replacedRegion
is not empty.Declaration
Swift
public func op(region: Region, op: RegionOperation) -> Bool
Parameters
rgn
Region
operandop
operator to apply
Return Value
false if result is empty
-
Undocumented
Declaration
Swift
public func op(path: Path, op inop: RegionOperation) -> Bool
-
Returns true if
Region
intersects other. Returns false if either other orRegion
is empty, or do not intersect.Declaration
Swift
public func intersects(region: Region) -> Bool
Parameters
other
Region
to intersectReturn Value
true if other and
Region
have area in common