cmykHalftone()
Adds a series of colorful dots to an image.
Declaration
class func cmykHalftone() -> any CIFilter & CICMYKHalftoneReturn Value
The modified image.
Discussion
This method applies a CMYK halftone filter to an image. The effect generates an image containing a series of dots. The dots contain only cyan, magenta, yellow, and black colors. Halftone effect is a set of lines, dots, or circles that contain detail. When viewing the image from a distance, the markings blend together creating the illusion of continuous lines and shapes. Print media commonly uses this effect.
The CMYK halftone filter uses the following properties:
inputImageAn image with the type CIImage.
angleA
floatrepresenting the angle of the pattern as an NSNumber.widthA
floatrepresenting the distance between dots in the pattern as an NSNumber.sharpnessA
floatrepresenting the sharpness of the pattern as an NSNumber.centerA set of coordinates marking the center of the image as a CGPoint.
grayComponentReplacementA
floatrepresenting the grey component to be replaced as an NSNumber.underColorRemovalA
floatrepresenting the under-color removal value as an NSNumber.
The following code produces an image with visible dots and less color:
func cmyk(inputImage: CIImage) -> CIImage {
let cmykHalftone = CIFilter.cmykHalftone()
cmykHalftone.inputImage = inputImage
cmykHalftone.angle = 1
cmykHalftone.width = 35
cmykHalftone.sharpness = 0.7
cmykHalftone.center = CGPoint(x: 2016, y: 1512)
cmykHalftone.grayComponentReplacement = 1
cmykHalftone.underColorRemoval = 0.1
return cmykHalftone.outputImage!
}[Image]