One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

MeshGradient

struct · iOS 18.0+ · SDK 27.1

nonisolated struct MeshGradient

A two-dimensional gradient defined by a 2D grid of positioned colors. Each vertex has a position, a color and four surrounding Bezier control points (leading, top, trailing, bottom) that define the tangents connecting the vertex with its four neighboring vertices. (Vertices on the corners or edges of the mesh have less than four neighbors, they ignore their extra control points.) Control points may either be specified explicitly or implicitly. When rendering, a tessellated sequence of Bezier patches are created, and vertex colors are interpolated across each patch, either linearly, or via another set of cubic curves derived from how the colors change between neighbors -- the latter typically gives smoother color transitions. MeshGradient(width: 3, height: 3, points: [ .init(0, 0), .init(0.5, 0), .init(1, 0), .init(0, 0.5), .init(0.5, 0.5), .init(1, 0.5), .init(0, 1), .init(0.5, 1), .init(1, 1) ], colors: [ .red, .purple, .indigo, .orange, .white, .blue, .yellow, .green, .mint ])

Members (19)

get · iOS 18.0+

background

TypeScript
get background(): Color
Swift declaration
var background: Color

The background color, this fills any points outside the defined vertex mesh.

set · iOS 18.0+

background

TypeScript
set background(value: Color)
Swift declaration
var background: Color

The background color, this fills any points outside the defined vertex mesh.

get · iOS 18.0+

colorSpace

TypeScript
get colorSpace(): Gradient_ColorSpace
Swift declaration
var colorSpace: Gradient.ColorSpace

The color space in which to interpolate vertex colors.

set · iOS 18.0+

colorSpace

TypeScript
set colorSpace(value: Gradient_ColorSpace)
Swift declaration
var colorSpace: Gradient.ColorSpace

The color space in which to interpolate vertex colors.

get · iOS 18.0+

smoothsColors

TypeScript
get smoothsColors(): boolean
Swift declaration
var smoothsColors: Bool

Whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh).

set · iOS 18.0+

smoothsColors

TypeScript
set smoothsColors(value: boolean)
Swift declaration
var smoothsColors: Bool

Whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh).

init · iOS 18.0+

init

TypeScript
static initWidthHeightBezierPointsResolvedColorsBackgroundSmoothsColorsColorSpace(width: number, height: number, bezierPoints: Array<MeshGradient_BezierPoint>, resolvedColors: Array<Color_Resolved>, background?: Color, smoothsColors?: boolean, colorSpace?: Gradient_ColorSpace): MeshGradient
Swift declaration
@export(implementation) nonisolated init(width: Int, height: Int, bezierPoints: [MeshGradient.BezierPoint], resolvedColors: [Color.Resolved], background: Color = .clear, smoothsColors: Bool = true, colorSpace: Gradient.ColorSpace = .device)

Creates a new gradient mesh specified as a 2D grid of colored points, specifying the Bezier control points explicitly, with already-resolved sRGB colors. - Parameters: - width: the width of the mesh, i.e. the number of vertices per row. - height: the height of the mesh, i.e. the number of vertices per column. - bezierPoints: the array of points and control points, containing `width x height` elements. - resolvedColors: the array of colors, containing `width x height` elements. - background: the background color, this fills any points outside the defined vertex mesh. - smoothsColors: whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh). - colorSpace: the color space in which to interpolate vertex colors.

init · iOS 18.0+

init

TypeScript
static initWidthHeightBezierPointsColorsBackgroundSmoothsColorsColorSpace(width: number, height: number, bezierPoints: Array<MeshGradient_BezierPoint>, colors: Array<Color>, background?: Color, smoothsColors?: boolean, colorSpace?: Gradient_ColorSpace): MeshGradient
Swift declaration
@export(implementation) nonisolated init(width: Int, height: Int, bezierPoints: [MeshGradient.BezierPoint], colors: [Color], background: Color = .clear, smoothsColors: Bool = true, colorSpace: Gradient.ColorSpace = .device)

Creates a new gradient mesh specified as a 2D grid of colored points, specifying the Bezier control points explicitly. - Parameters: - width: the width of the mesh, i.e. the number of vertices per row. - height: the height of the mesh, i.e. the number of vertices per column. - bezierPoints: the array of points and control points, containing `width x height` elements. - colors: the array of colors, containing `width x height` elements. - background: the background color, this fills any points outside the defined vertex mesh. - smoothsColors: whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh). - colorSpace: the color space in which to interpolate vertex colors.

init · iOS 18.0+

init

TypeScript
static initWidthHeightPointsResolvedColorsBackgroundSmoothsColorsColorSpace(width: number, height: number, points: Array<SDKHandle>, resolvedColors: Array<Color_Resolved>, background?: Color, smoothsColors?: boolean, colorSpace?: Gradient_ColorSpace): MeshGradient
Swift declaration
@export(implementation) nonisolated init(width: Int, height: Int, points: [SIMD2<Float>], resolvedColors: [Color.Resolved], background: Color = .clear, smoothsColors: Bool = true, colorSpace: Gradient.ColorSpace = .device)

Creates a new gradient mesh specified as a 2D grid of colored points, with already-resolved sRGB colors. - Parameters: - width: the width of the mesh, i.e. the number of vertices per row. - height: the height of the mesh, i.e. the number of vertices per column. - points: the array of points, containing `width x height` elements. - resolvedColors: the array of colors, containing `width x height` elements. - background: the background color, this fills any points outside the defined vertex mesh. - smoothsColors: whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh). - colorSpace: the color space in which to interpolate vertex colors.

init · iOS 18.0+

init

TypeScript
static initWidthHeightPointsColorsBackgroundSmoothsColorsColorSpace(width: number, height: number, points: Array<SDKHandle>, colors: Array<Color>, background?: Color, smoothsColors?: boolean, colorSpace?: Gradient_ColorSpace): MeshGradient
Swift declaration
@export(implementation) nonisolated init(width: Int, height: Int, points: [SIMD2<Float>], colors: [Color], background: Color = .clear, smoothsColors: Bool = true, colorSpace: Gradient.ColorSpace = .device)

Creates a new gradient mesh specified as a 2D grid of colored points. - Parameters: - width: the width of the mesh, i.e. the number of vertices per row. - height: the height of the mesh, i.e. the number of vertices per column. - points: the array of points, containing `width x height` elements. - colors: the array of colors, containing `width x height` elements. - background: the background color, this fills any points outside the defined vertex mesh. - smoothsColors: whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh). - colorSpace: the color space in which to interpolate vertex colors.

init · iOS 18.0+

init

TypeScript
static initWidthHeightLocationsColorsBackgroundSmoothsColorsColorSpace(width: number, height: number, locations: MeshGradient_Locations, colors: MeshGradient_Colors, background?: Color, smoothsColors?: boolean, colorSpace?: Gradient_ColorSpace): MeshGradient
Swift declaration
nonisolated init(width: Int, height: Int, locations: MeshGradient.Locations, colors: MeshGradient.Colors, background: Color = .clear, smoothsColors: Bool = true, colorSpace: Gradient.ColorSpace = .device)

Creates a new gradient mesh specified as a 2D grid of colored vertices. - Parameters: - width: the width of the mesh, i.e. the number of vertices per row. - height: the height of the mesh, i.e. the number of vertices per column. - locations: the array of locations, containing `width x height` elements. - colors: the array of colors, containing `width x height` elements. - background: the background color, this fills any points outside the defined vertex mesh. - smoothsColors: whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh). - colorSpace: the color space in which to interpolate vertex colors.

get · iOS 18.0+

width

TypeScript
get width(): number
Swift declaration
var width: Int

The width of the mesh, i.e. the number of vertices per row.

set · iOS 18.0+

width

TypeScript
set width(value: number)
Swift declaration
var width: Int

The width of the mesh, i.e. the number of vertices per row.

get · iOS 18.0+

colors

TypeScript
get colors(): MeshGradient_Colors
Swift declaration
var colors: MeshGradient.Colors

The array of colors. Must contain `width x height` elements.

set · iOS 18.0+

colors

TypeScript
set colors(value: MeshGradient_Colors)
Swift declaration
var colors: MeshGradient.Colors

The array of colors. Must contain `width x height` elements.

get · iOS 18.0+

height

TypeScript
get height(): number
Swift declaration
var height: Int

The height of the mesh, i.e. the number of vertices per column.

set · iOS 18.0+

height

TypeScript
set height(value: number)
Swift declaration
var height: Int

The height of the mesh, i.e. the number of vertices per column.

get · iOS 18.0+

locations

TypeScript
get locations(): MeshGradient_Locations
Swift declaration
var locations: MeshGradient.Locations

The array of locations. Must contain `width x height` elements.

set · iOS 18.0+

locations

TypeScript
set locations(value: MeshGradient_Locations)
Swift declaration
var locations: MeshGradient.Locations

The array of locations. Must contain `width x height` elements.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUICore types →