<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GraphicsContext/Shading/shader(_:bounds:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15GraphicsContextV7ShadingV6shader_6boundsAeA6ShaderV_So6CGRectVtFZ"
  },
  "title" : "shader(_:bounds:)"
}
-->

# shader(_:bounds:)

Returns a shading instance that fills with the results of
querying a shader for each pixel.

```
static func shader(_ shader: Shader, bounds: CGRect = .zero) -> GraphicsContext.Shading
```

## Parameters

`shader`

The shader defining the filled colors.

`bounds`

The rect used to define any `bounds` arguments
of the shader.

## Return Value

A shading instance that fills using the shader.

## Discussion

For a shader function to act as a shape fill it must have a
function signature matching:

```
[[ stitchable ]] half4 name(float2 position, args...)
```

where `position` is the user-space coordinates of the pixel applied
to the shader, and `args...` should be compatible with the uniform
arguments bound to `shader`. The function should return the
premultiplied color value in the color space of the destination
(typically sRGB).

---

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)