Contents

starShineGenerator()

Generates a star-shine image.

Declaration

class func starShineGenerator() -> any CIFilter & CIStarShineGenerator

Return Value

The generated image.

Discussion

This method generates a star-shine image. The effect is similar to a supernova effect. You can use this filter to simulate a lens flare.

The star-shine generator filter uses the following properties:

center

A vector representing the center of the flare as a CGPoint.

color

A color representing the color of the flare as a cgColor.

radius

A float representing the radius of the flare as an NSNumber.

crossScale

A float representing the cross flare size relative to the round central flare as an NSNumber.

crossAngle

A float representing the angle of the flare as an NSNumber.

crossOpacity

A float representing the thickness of the cross opacity as an NSNumber.

crossWidth

A float representing the cross width as an NSNumber.

epsilon

A float representing the epsilon as an NSNumber.

The following code generates a star-shaped silhouette with a black background.

func starShine() -> CIImage {
    let starShineGenerator = CIFilter.starShineGenerator()
    starShineGenerator.center = CGPoint(x: 150, y: 150)
    starShineGenerator.color = .green
    starShineGenerator.radius = 50
    starShineGenerator.crossScale = 15
    starShineGenerator.crossAngle = 0.60
    starShineGenerator.crossOpacity = -2
    starShineGenerator.crossWidth = 2.5
    starShineGenerator.epsilon = -2.0
    return starShineGenerator.outputImage!
}

[Image]

See Also

Filters