---
title: CGFunction
framework: coregraphics
role: symbol
role_heading: Class
path: coregraphics/cgfunction
---

# CGFunction

A general facility for defining and using callback functions.

## Declaration

```swift
class CGFunction
```

## Overview

Overview These functions can take an arbitrary number of floating-point input values and pass back an arbitrary number of floating-point output values. Core Graphics uses function objects to implement shadings. CGShading describes the parameters and semantics required for the callbacks used by function objects.

## Topics

### Creating Function Objects

- [init(info:domainDimension:domain:rangeDimension:range:callbacks:)](coregraphics/cgfunction/init(info:domaindimension:domain:rangedimension:range:callbacks:).md)

### Callbacks

- [CGFunctionCallbacks](coregraphics/cgfunctioncallbacks.md)
- [CGFunctionEvaluateCallback](coregraphics/cgfunctionevaluatecallback.md)
- [CGFunctionReleaseInfoCallback](coregraphics/cgfunctionreleaseinfocallback.md)

### Working with Core Foundation Types

- [typeID](coregraphics/cgfunction/typeid.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Related Documentation

- [Quartz 2D Programming Guide](apple-archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction.md)

### Utility and Support Classes

- [CGDataConsumer](coregraphics/cgdataconsumer.md)
- [CGDataProvider](coregraphics/cgdataprovider.md)
- [CGShading](coregraphics/cgshading.md)
- [CGGradient](coregraphics/cggradient.md)
- [CGPattern](coregraphics/cgpattern.md)
