<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIFilter-swift.class/meshGenerator()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter(cm)meshGeneratorFilter"
  },
  "title" : "meshGenerator()"
}
-->

# meshGenerator()

Generates a pattern made from an array of line segments.

```
class func meshGenerator() -> any CIFilter & CIMeshGenerator
```

## Return Value

The generated image.

## Discussion

This method generates a mesh generator image. The effect uses an array of line segments to create the resulting image.

The mesh generator filter uses the following properties:

- `inputMesh`: An `array` of line segments stored as an array of [`CIVector`](/documentation/CoreImage/CIVector), each containing a start point and end point.
- `color`: A [`CIColor`](/documentation/CoreImage/CIColor) representing the color used to make the mesh.
- `width`: A `float` representing the width of the line segments as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>

The following code creates a filter that generates a green star made from mesh segments:

```swift
func mesh(mesh: NSdata) -> CIImage {
    let meshGenerator = CIFilter.meshGenerator()
    meshGenerator.color = CIColor.green
    meshGenerator.width = 3
    meshGenerator.inputmesh = mesh
    return meshGenerator.outputImage!
}
```

![A set of green mesh line segments connected together to draw a five-point star pattern.](images/com.apple.coreimage/media-3590974@2x.png)

---

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)