RectangleProtocol

public protocol RectangleProtocol

The RectangleProtocol protocol exposes the methods and properties of an underlying GdkRectangle instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Rectangle. Alternatively, use RectangleRef as a lighweight, unowned reference if you already have an instance you just want to use.

A GdkRectangle data type for representing rectangles.

GdkRectangle is identical to cairo_rectangle_t. Together with Cairo’s cairo_region_t data type, these are the central types for representing sets of pixels.

The intersection of two rectangles can be computed with [methodGdk.Rectangle.intersect]; to find the union of two rectangles use [methodGdk.Rectangle.union].

The cairo_region_t type provided by Cairo is usually used for managing non-rectangular clipping of graphical operations.

The Graphene library has a number of other data types for regions and volumes in 2D and 3D.

  • ptr

    Untyped pointer to the underlying GdkRectangle instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • rectangle_ptr Default implementation

    Typed pointer to the underlying GdkRectangle instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GdkRectangle instance.

    Declaration

    Swift

    var rectangle_ptr: UnsafeMutablePointer<GdkRectangle>! { get }
  • Required Initialiser for types conforming to RectangleProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Rectangle Record: RectangleProtocol extension (methods and fields)

  • containsPoint(x:y:) Extension method

    Returns TRUE if rect contains the point described by x and y.

    Declaration

    Swift

    @inlinable
    func containsPoint(x: Int, y: Int) -> Bool
  • equal(rect2:) Extension method

    Checks if the two given rectangles are equal.

    Declaration

    Swift

    @inlinable
    func equal<RectangleT>(rect2: RectangleT) -> Bool where RectangleT : RectangleProtocol
  • intersect(src2:dest:) Extension method

    Calculates the intersection of two rectangles.

    It is allowed for dest to be the same as either src1 or src2. If the rectangles do not intersect, dest’s width and height is set to 0 and its x and y values are undefined. If you are only interested in whether the rectangles intersect, but not in the intersecting area itself, pass nil for dest.

    Declaration

    Swift

    @inlinable
    func intersect<RectangleT>(src2: RectangleT, dest: RectangleT?) -> Bool where RectangleT : RectangleProtocol
  • union(src2:dest:) Extension method

    Calculates the union of two rectangles.

    The union of rectangles src1 and src2 is the smallest rectangle which includes both src1 and src2 within it. It is allowed for dest to be the same as either src1 or src2.

    Note that this function does not ignore ‘empty’ rectangles (ie. with zero width or height).

    Declaration

    Swift

    @inlinable
    func union<RectangleT>(src2: RectangleT, dest: RectangleT) where RectangleT : RectangleProtocol
  • cairoRectangle(cr:) Extension method

    Adds the given rectangle to the current path of cr.

    Declaration

    Swift

    @inlinable
    func cairoRectangle<ContextT>(cr: ContextT) where ContextT : ContextProtocol
  • x Extension method

    the x coordinate of the top left corner

    Declaration

    Swift

    @inlinable
    var x: gint { get set }
  • y Extension method

    the y coordinate of the top left corner

    Declaration

    Swift

    @inlinable
    var y: gint { get set }
  • width Extension method

    the width of the rectangle

    Declaration

    Swift

    @inlinable
    var width: gint { get set }
  • height Extension method

    the height of the rectangle

    Declaration

    Swift

    @inlinable
    var height: gint { get set }