linearGradient()
Generates a color gradient that varies along a linear axis between two defined endpoints.
Declaration
class func linearGradient() -> any CIFilter & CILinearGradientMentioned in
Return Value
The generated image.
Discussion
This method generates a linear-gradient image. The effect creates a gradient that varies linearly between the two input properties of point0 and point1.
The linear-gradient filter uses the following properties:
point0A CGPoint representing the starting position of the gradient.
point1A CGPoint representing the ending position of the gradient.
color0A CIColor representing the first color to use in the gradient.
color1A CIColor representing the second color to use the gradient.
The following code creates a filter that generates a gradient image:
func linear() -> CIImage {
let linearGradient = CIFilter.linearGradient()
linearGradient.point0 = CGPoint(x: 0, y: 0)
linearGradient.point1 = CGPoint(x: 200, y: 200)
linearGradient.color0 = CIColor(red: 216/255, green: 232/255, blue: 146/255)
linearGradient.color1 = CIColor(red: 0/255, green: 112/255, blue: 201/255)
return linearGradient.outputImage!
}[Image]