---
title: "setFillColor(red:green:blue:alpha:)"
framework: coregraphics
role: symbol
role_heading: Instance Method
path: "coregraphics/cgcontext/setfillcolor(red:green:blue:alpha:)"
---

# setFillColor(red:green:blue:alpha:)

Sets the current fill color to a value in the DeviceRGB color space.

## Declaration

```swift
func setFillColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)
```

## Parameters

- `red`: The red intensity value for the color to set. The DeviceRGB color space permits the specification of a value ranging from 0.0 (zero intensity) to 1.0 (full intensity).
- `green`: The green intensity value for the color to set. The DeviceRGB color space permits the specification of a value ranging from 0.0 (zero intensity) to 1.0 (full intensity).
- `blue`: The blue intensity value for the color to set. The DeviceRGB color space permits the specification of a value ranging from 0.0 (zero intensity) to 1.0 (full intensity).
- `alpha`: A value that specifies the opacity level. Values can range from 0.0 (transparent) to 1.0 (opaque). Values outside this range are clipped to 0.0 or 1.0.

## Discussion

Discussion When you call this function, two things happen: Core Graphics sets the current fill color space to DeviceRGB. Core Graphics sets the current fill color to the value specified by the red, green, blue, and alpha parameters.

## See Also

### Setting Fill, Stroke, and Shadow Colors

- [setFillColor(_:)](coregraphics/cgcontext/setfillcolor(_:)-8lhn8.md)
- [setFillColor(_:)](coregraphics/cgcontext/setfillcolor(_:)-756dy.md)
- [setFillColor(cyan:magenta:yellow:black:alpha:)](coregraphics/cgcontext/setfillcolor(cyan:magenta:yellow:black:alpha:).md)
- [setFillColor(gray:alpha:)](coregraphics/cgcontext/setfillcolor(gray:alpha:).md)
- [setFillColorSpace(_:)](coregraphics/cgcontext/setfillcolorspace(_:).md)
- [setShadow(offset:blur:)](coregraphics/cgcontext/setshadow(offset:blur:).md)
- [setShadow(offset:blur:color:)](coregraphics/cgcontext/setshadow(offset:blur:color:).md)
- [setStrokeColor(_:)](coregraphics/cgcontext/setstrokecolor(_:)-1sskg.md)
- [setStrokeColor(_:)](coregraphics/cgcontext/setstrokecolor(_:)-4pd8p.md)
- [setStrokeColor(cyan:magenta:yellow:black:alpha:)](coregraphics/cgcontext/setstrokecolor(cyan:magenta:yellow:black:alpha:).md)
- [setStrokeColor(gray:alpha:)](coregraphics/cgcontext/setstrokecolor(gray:alpha:).md)
- [setStrokeColor(red:green:blue:alpha:)](coregraphics/cgcontext/setstrokecolor(red:green:blue:alpha:).md)
- [setStrokeColorSpace(_:)](coregraphics/cgcontext/setstrokecolorspace(_:).md)
- [setStrokePattern(_:colorComponents:)](coregraphics/cgcontext/setstrokepattern(_:colorcomponents:).md)
- [setAlpha(_:)](coregraphics/cgcontext/setalpha(_:).md)
