ios – CIGaussianFilter shouldn’t be centering impact


On iOS, I wish to apply a CIGaussianFilter on an SKSpriteNode which is a full display screen picture, nevertheless the blurred picture does not stay centered.

let blur = CIFilter(identify:"CIGaussianBlur",parameters: ["inputRadius": 20.0])
effectsNode = SKEffectNode()
effectsNode.filter = blur
effectsNode.blendMode = .alpha
effectsNode.shouldCenterFilter = true
effectsNode.shouldEnableEffects = true
effectsNode.shouldRasterize = false

UIGraphicsBeginImageContextWithOptions(self.view!.bounds.dimension, true, 0)
view!.drawHierarchy(in: self.view!.bounds, afterScreenUpdates: true)
let picture = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let nodeToBlur = SKSpriteNode(texture:SKTexture(picture: picture!))
                
self.effectsNode.addChild(nodeToBlur)

However the extra the picture is blurred, the extra it is going to get to the upper-left a part of the display screen. How can I keep away from this and preserve the picture centered ?
enter image description here

Leave a Reply