GraphicsContextShading

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

StructureiOS 15.0+macOS 12.0+tvOS 15.0+watchOS 8.0+GraphicsContext.Shading in SwiftUI

Declaration

React
type GraphicsContextShading =
  | 'backdrop'
  | 'foreground'
  | { color: { colorSpace?: ColorRGBColorSpace; red: number; green: number; blue: number; opacity?: number; }; }
  | { color: { colorSpace?: ColorRGBColorSpace; white: number; opacity?: number; }; }
  | { color: Color; }
  | { conicGradient: { gradient: Gradient; center: CGPoint; angle?: Angle; options?: GraphicsContextGradientOptions; }; }
  | { linearGradient: { gradient: Gradient; startPoint: CGPoint; endPoint: CGPoint; options?: GraphicsContextGradientOptions; }; }
  | { meshGradient: MeshGradient; }
  | { palette: GraphicsContextShading[]; }
  | { radialGradient: { gradient: Gradient; center: CGPoint; startRadius: number; endRadius: number; options?: GraphicsContextGradientOptions; }; }
  | { radialGradient: { gradient: Gradient; startCenter: CGPoint; startRadius: number; endCenter: CGPoint; endRadius: number; options?: GraphicsContextGradientOptions; }; }
  | { shader: { shader: Shader; bounds?: CGRect; }; }
  | { style: ShapeStyle; }
  | { tiledImage: { image: Image; origin?: CGPoint; sourceRect?: CGRect; scale?: number; }; };
Swift
struct Shading

Pass a literal, or build one with SwiftUI.GraphicsContextShading from import { SwiftUI } from 'swiftui-react-native'.

Type properties

Type methods

Overview

Use a shading instance to describe the color or pattern of a path that you outline with a method like stroke(_:with:style:), or of the interior of a region that you fill with the 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.
  • A Gradient.
  • Any type that conforms to ShapeStyle.
  • An Image.
  • What you've already drawn into the context.
  • A collection of other shading instances.

From Apple’s SwiftUI documentation. Code samples there are Swift.

See also

More in Drawing and shapes.