Contents

roundedRectangleGenerator()

Generates a rounded rectangle image.

Declaration

class func roundedRectangleGenerator() -> any CIFilter & CIRoundedRectangleGenerator

Return Value

The generated image.

Discussion

This method generates a rounded rectangle image with the specified size, corner radius, and color properties.

The rounded rectangle generator filter uses the following properties:

color

A CIColor representing the color of the rounded rectangle.

extent

A CGRect representing the size of the rounded rectangle.

radius

A float representing the curve of the rectangle’s corners.

The following code creates a filter that generates a light blue square with rounded corners:

func roundedRectangle () -> CIImage {
    let roundedRectangleGenerator = CIFilter.roundedRectangleGenerator()
    roundedRectangleGenerator.color = CIColor(red: 96/255, green: 173/255, blue: 193/255)
    roundedRectangleGenerator.extent = CGRect(x: 0, y: 1, width: 700, height: 700)
    roundedRectangleGenerator.radius = 100
    return roundedRectangleGenerator.outputImage!
}

[Image]

See Also

Filters