<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/MeshGradient/init(width:height:points:colors:background:smoothsColors:colorSpace:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12MeshGradientV5width6height6points6colors10background13smoothsColors10colorSpaceACSi_SiSays5SIMD2VySfGGSayAA5ColorVGAPSbAA0D0V0oM0Vtcfc"
  },
  "title" : "init(width:height:points:colors:background:smoothsColors:colorSpace:)"
}
-->

# init(width:height:points:colors:background:smoothsColors:colorSpace:)

Creates a new gradient mesh specified as a 2D grid of colored
points.

```
@export(implementation) nonisolated init(width: Int, height: Int, points: [SIMD2<Float>], colors: [Color], background: Color = .clear, smoothsColors: Bool = true, colorSpace: Gradient.ColorSpace = .device)
```

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)