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 a Region 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 constructed Region is empty. Constructed Region 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 outline

    clip

    Region containing path

    Return 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 of Region op rect. Returns true if replaced Region is not empty.

    Declaration

    Swift

    public func op(rect: IRect, op: RegionOperation) -> Bool

    Parameters

    rect

    IRect operand

    op

    operator to apply

    Return Value

    false if result is empty

  • Replaces Region with the result of Region op rgn. Returns true if replaced Region is not empty.

    Declaration

    Swift

    public func op(region: Region, op: RegionOperation) -> Bool

    Parameters

    rgn

    Region operand

    op

    operator to apply

    Return Value

    false if result is empty

  • Undocumented

    Declaration

    Swift

    public func op(path: Path, op inop: RegionOperation) -> Bool
  • Returns minimum and maximum axes values of IRect array. Returns (0, 0, 0, 0) if Region is empty.

    Declaration

    Swift

    public var bounds: IRect { get }
  • Returns true if Region intersects other. Returns false if either other or Region is empty, or do not intersect.

    Declaration

    Swift

    public func intersects(region: Region) -> Bool

    Parameters

    other

    Region to intersect

    Return Value

    true if other and Region have area in common

  • Returns true if Region intersects rect. Returns false if either rect or Region is empty, or do not intersect.

    Declaration

    Swift

    public func intersects(rect: IRect) -> Bool

    Parameters

    rect

    IRect to intersect

    Return Value

    true if rect and Region have area in common