public protocol Generator

The Generator protocol declares a variable and a method that are required by Generator object so it can properly interface with Core Image.

  • The name of the Core Image filter (e.g. CICheckerboardGenerator)



    var filterName: String { get }
  • Creates a Core Image filter using specified input image.

    This method is used internally by Image when applying filters to its layer’s contents.

    public func createCoreImageFilter(inputImage: CIImage) -> CIFilter {
        let filter = CIFilter(name: filterName)!
        filter.setValue(CIColor(colors[0]), forKey:"inputColor0")
        filter.setValue(CIColor(colors[1]), forKey:"inputColor1")
        filter.setValue(width, forKey: "inputWidth")
        filter.setValue(CIVector(CGPoint: CGPoint(center)), forKey:"inputCenter")
        filter.setValue(sharpness, forKey: "inputSharpness")
        return filter

    A specific filter will have internal properties whose values are applied to the CIFilter being generated. However, those properties are object / filter specific and so cannot be defined in the protocol.



    func createCoreImageFilter() -> CIFilter

    Return Value

    A CIFilter whose name is filterName and whose contents are generated by the filter itself.