---
title: "color(_:red:green:blue:opacity:)"
framework: swiftui
role: symbol
role_heading: Type Method
path: "swiftui/graphicscontext/shading/color(_:red:green:blue:opacity:)"
---

# color(_:red:green:blue:opacity:)

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

## Declaration

```swift
static func color(_ colorSpace: Color.RGBColorSpace = .sRGB, red: Double, green: Double, blue: Double, opacity: Double = 1) -> GraphicsContext.Shading
```

## Parameters

- `colorSpace`: The RGB color space used to define the color. The default is doc://com.apple.SwiftUI/documentation/SwiftUI/Color/RGBColorSpace/sRGB.
- `red`: The red component of the color.
- `green`: The green component of the color.
- `blue`: The blue component of the color.
- `opacity`: The opacity of the color. The default is 1, which means fully opaque.

## Return Value

Return Value A shading instance filled with a color.

## See Also

### Colors

- [color(_:)](swiftui/graphicscontext/shading/color(_:).md)
- [color(_:white:opacity:)](swiftui/graphicscontext/shading/color(_:white:opacity:).md)
