spotLight()
Highlights a definined area of the image.
Declaration
class func spotLight() -> any CIFilter & CISpotLightReturn Value
The modified image.
Discussion
This method applies the spotlight filter to an image. The effect applies a directional spotlight effect to an image while creating a transparent area not highlighted by the spotlight.
The spotlight filter uses the following properties:
inputImageAn image with the type CIImage.
lightPointsAtA CIVector with the x and y positions that the spotlight points at.
brightnessA
floatrepresenting the brightness of the spotlight as an NSNumber.lightPositionA CIVector containing the x and y position of the spotlight.
concentrationA
floatrepresenting the size of the spotlight in pixels as an NSNumber.colorA CIColor representing the spotlight color.
The following code creates a filter that results in only the bottom left of the image becoming visible while the rest of the image gradually becomes transparent:
func spotlight(inputImage: CIImage) -> CIImage {
let spotlightFilter = CIFilter.spotLight()
spotlightFilter.inputImage = inputImage
spotlightFilter.lightPointsAt = CIVector(x: 100, y: 100)
spotlightFilter.brightness = 10
spotlightFilter.lightPosition = CIVector(x: 100, y: 100)
spotlightFilter.concentration = 20
return spotlightFilter.outputImage!
}[Image]