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.
-
Untyped pointer to the underlying
GdkRectangle
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
rectangle_ptr
Default implementationTyped 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)
-
containsPoint(x:
Extension methody: ) 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:
Extension methoddest: ) Calculates the intersection of two rectangles.
It is allowed for
dest
to be the same as eithersrc1
orsrc2
. 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, passnil
fordest
.Declaration
Swift
@inlinable func intersect<RectangleT>(src2: RectangleT, dest: RectangleT?) -> Bool where RectangleT : RectangleProtocol
-
union(src2:
Extension methoddest: ) Calculates the union of two rectangles.
The union of rectangles
src1
andsrc2
is the smallest rectangle which includes bothsrc1
andsrc2
within it. It is allowed fordest
to be the same as eithersrc1
orsrc2
.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 methodthe x coordinate of the top left corner
Declaration
Swift
@inlinable var x: gint { get set }
-
y
Extension methodthe y coordinate of the top left corner
Declaration
Swift
@inlinable var y: gint { get set }
-
width
Extension methodthe width of the rectangle
Declaration
Swift
@inlinable var width: gint { get set }
-
height
Extension methodthe height of the rectangle
Declaration
Swift
@inlinable var height: gint { get set }