flashTransition()
Creates a flash of light to transition between two images.
Declaration
class func flashTransition() -> any CIFilter & CIFlashTransitionReturn Value
The transition image.
Discussion
This method applies the flash transition filter to an image. The effect transitions from the input image to the target image by creating a flash that fills the image and fades to the target image.
The flash transition filter uses the following properties:
inputImageThe starting image with the type CIImage.
targetImageThe ending image with the type CIImage.
centerA set of coordinates marking the center of the image as a CGPoint.
extentA CGRect representing the size of the rounded rectangle.
colorA CIColor representing the color of the flash effect.
timeA
floatrepresenting the parametric time of the transition from start (at time 0) to end (at time 1) as an NSNumber.maxStiriationRadiusA
floatrepresenting the radius of the light rays emanating from the flash as a NSNumber.striationStrengthA
floatrepresenting the strength of the light rays emanating from the flash as a NSNumber.striationContrastA
floatrepresenting the contrast that’s added to each output pixel as a NSNumber.fadeThresholdA
floatrepresenting the amount of fade between the flash and the target image as a NSNumber.
The following code creates a filter that transitions from the input image with a large flash of light and fades to the target image.
func flash (inputImage: CIImage, targetImage: CIImage) -> CIImage {
let flashTransition = CIFilter.flashTransition()
flashTransition.inputImage = inputImage
flashTransition.targetImage = targetImage
flashTransition.center = CGPoint(x: 253, y: 372)
flashTransition.extent = CGRect(x: 0, y: 0, width: 300, height: 300)
flashTransition.color = .white
flashTransition.time = 0.5
flashTransition.maxStriationRadius = 2.58
flashTransition.striationStrength = 0.5
flashTransition.striationContrast = 1.375
flashTransition.fadeThreshold = 0.06
return flashTransition.outputImage!
}[Image]