One Logo Pool Ball
Vision · IOS API REFERENCE

NormalizedRect

struct · iOS 18.0+ · SDK 27.1

struct NormalizedRect

A rectangle with normalized coordinates in the range [0, 1].

Members (13)

init · iOS 18.0+

init

TypeScript
static initNormalizedRect(normalizedRect: { x: number; y: number; width: number; height: number }): NormalizedRect
Swift declaration
init(normalizedRect: CGRect)

Creates a rectangle from the specified Core Graphics rectangle.

get · iOS 18.0+

cgRect

TypeScript
get cgRect(): { x: number; y: number; width: number; height: number }
Swift declaration
let cgRect: CGRect

The normalized rectangle as a CGRect.

init · iOS 18.0+

init

TypeScript
static initImageRectInNormalizedTo(imageRect: { x: number; y: number; width: number; height: number }, imageSize: { width: number; height: number }, regionOfInterest: NormalizedRect): NormalizedRect
Swift declaration
init(imageRect: CGRect, in imageSize: CGSize, normalizedTo regionOfInterest: NormalizedRect)

Creates a rectangle normalized to a region of interest in an image from a rectangle in an image coordinate space. - Parameters: - imageRect: A rectangle in the image coordinate space. - imageSize: The size of the image.

init · iOS 18.0+

init

TypeScript
static initImageRectIn(imageRect: { x: number; y: number; width: number; height: number }, imageSize: { width: number; height: number }): NormalizedRect
Swift declaration
init(imageRect: CGRect, in imageSize: CGSize)

Creates a normalized rectangle from a rectangle in an image coordinate space. - Parameters: - imageRect: A rectangle in the image coordinate space. - imageSize: The size of the image.

get · iOS 18.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

method · iOS 18.0+

verticallyFlipped

TypeScript
verticallyFlipped(): NormalizedRect
Swift declaration
func verticallyFlipped() -> NormalizedRect

Returns a `NormalizedRect` with the origin flipped between the top and bottom of the image.

method · iOS 18.0+

toImageCoordinates

TypeScript
toImageCoordinatesFromImageSizeOrigin(regionOfInterest: NormalizedRect, imageSize: { width: number; height: number }, origin?: CoordinateOrigin): { x: number; y: number; width: number; height: number }
Swift declaration
func toImageCoordinates(from regionOfInterest: NormalizedRect, imageSize: CGSize, origin: CoordinateOrigin = .lowerLeft) -> CGRect

Converts a rectangle normalized to a region within an image into full image coordinates. - Parameters: - imageSize: The size of the image. - regionOfInterest: The region within an image the `NormalizedPoint` is normalized to.

method · iOS 18.0+

toImageCoordinates

TypeScript
toImageCoordinatesOrigin(imageSize: { width: number; height: number }, origin?: CoordinateOrigin): { x: number; y: number; width: number; height: number }
Swift declaration
func toImageCoordinates(_ imageSize: CGSize, origin: CoordinateOrigin = .lowerLeft) -> CGRect

Converts a rectangle in normalized coordinates into image coordinates. - Parameters: - imageSize: The size of the image.

init · iOS 18.0+

init

TypeScript
static initXYWidthHeight(x: number, y: number, width: number, height: number): NormalizedRect
Swift declaration
init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat)

Creates a rectangle with the specified coordinates. - Parameters: - x: The x-coordinate of the rectangle's lower-left corner. - y: The y-coordinate of the rectangle's lower-left corner.. - width: The width of the rectangle - height: The height of the rectangle

get · iOS 18.0+

width

TypeScript
get width(): number
Swift declaration
var width: CGFloat { get }

The width of the rectangle

get · iOS 18.0+

height

TypeScript
get height(): number
Swift declaration
var height: CGFloat { get }

The height of the rectangle

get · iOS 18.0+

origin

TypeScript
get origin(): { x: number; y: number }
Swift declaration
var origin: CGPoint { get }

The lower-left hand corner of the rectangle.

get · iOS 18.0+

fullImage

TypeScript
static get fullImage(): NormalizedRect
Swift declaration
static var fullImage: NormalizedRect { get }

A normalized rectangle with origin at [0,0] and a width and height of 1.0.

Skipped declarations

No declarations were skipped in this snapshot.

All Vision types →