<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GraphicsContext/Shading",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15GraphicsContextV7ShadingV"
  },
  "title" : "GraphicsContext.Shading"
}
-->

# GraphicsContext.Shading

A color or pattern that you can use to outline or fill a path.

```
struct Shading
```

## Overview

Use a shading instance to describe the color or pattern of a path that
you outline with a method like [`stroke(_:with:style:)`](/documentation/SwiftUI/GraphicsContext/stroke(_:with:style:)), or of the
interior of a region that you fill with the [`fill(_:with:style:)`](/documentation/SwiftUI/GraphicsContext/fill(_:with:style:))
method. Get a shading instance by calling one of the `Shading`
structure’s factory methods. You can base shading on:

- A [`Color`](/documentation/SwiftUI/Color).
- A [`Gradient`](/documentation/SwiftUI/Gradient).
- Any type that conforms to [`ShapeStyle`](/documentation/SwiftUI/ShapeStyle).
- An [`Image`](/documentation/SwiftUI/Image).
- What you’ve already drawn into the context.
- A collection of other shading instances.

## Topics

### Colors

[`static func color(Color) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/color(_:))

Returns a shading instance that fills with a color.

[`static func color(Color.RGBColorSpace, red: Double, green: Double, blue: Double, opacity: Double) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/color(_:red:green:blue:opacity:))

Returns a shading instance that fills with a color in the given
color space.

[`static func color(Color.RGBColorSpace, white: Double, opacity: Double) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/color(_:white:opacity:))

Returns a shading instance that fills with a monochrome color in
the given color space.

### Gradients

[`static linearGradient(_:startPoint:endPoint:options:)`](/documentation/SwiftUI/GraphicsContext/Shading/linearGradient(_:startPoint:endPoint:options:))

Returns a shading instance that fills a linear (axial) gradient.

[`static radialGradient(_:center:startRadius:endRadius:options:)`](/documentation/SwiftUI/GraphicsContext/Shading/radialGradient(_:center:startRadius:endRadius:options:))

Returns a shading instance that fills a radial gradient.

[`static conicGradient(_:center:angle:options:)`](/documentation/SwiftUI/GraphicsContext/Shading/conicGradient(_:center:angle:options:))

Returns a shading instance that fills a conic (angular) gradient.

### Other shape styles

[`static func style<S>(S) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/style(_:))

Returns a shading instance that fills with the given shape style.

[`static var foreground: GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/foreground)

A shading instance that fills with the foreground style from
the graphics context’s environment.

### Images

[`static func tiledImage(Image, origin: CGPoint, sourceRect: CGRect, scale: CGFloat) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/tiledImage(_:origin:sourceRect:scale:))

Returns a shading instance that tiles an image across the infinite
plane.

### Composite shading types

[`static func palette([GraphicsContext.Shading]) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/palette(_:))

Returns a multilevel shading instance constructed from an
array of shading instances.

[`static var backdrop: GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/backdrop)

A shading instance that draws a copy of the current background.

### Using a custom Metal shader

[`static func shader(Shader, bounds: CGRect) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/shader(_:bounds:))

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

### Type Methods

[`static func meshGradient(MeshGradient) -> GraphicsContext.Shading`](/documentation/SwiftUI/GraphicsContext/Shading/meshGradient(_:))

Returns a shading instance that fills with a mesh gradient.

[`static radialGradient(_:startCenter:startRadius:endCenter:endRadius:options:)`](/documentation/SwiftUI/GraphicsContext/Shading/radialGradient(_:startCenter:startRadius:endCenter:endRadius:options:))

Returns a shading that fills a two-point radial gradient.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)