objcio / issue-16-functional-apis

Example playground for the article http://www.objc.io/issue16/functional-swift-apis.html
13 stars 3 forks source link

Any luck working through this in a playground? #1

Open jonnolen opened 10 years ago

jonnolen commented 10 years ago

I'm following along at home, but I can't get CIImage objects to work in a swift playground? Anyone have any luck with this?

myplayground playground 2014-10-01 16-50-32

pyanfield commented 10 years ago

Maybe it's a bug of playground , because it works as below code:

import UIKit

let image = UIImage(named: "cover")

let gaussianBlurFilter = CIFilter(name: "CIGaussianBlur")
gaussianBlurFilter.setValue(CIImage(image: image), forKey: kCIInputImageKey)
gaussianBlurFilter.setValue(10, forKey: kCIInputRadiusKey)

let ctx = CIContext(options:nil)
let cgImage = ctx.createCGImage(gaussianBlurFilter.outputImage, fromRect:gaussianBlurFilter.outputImage.extent())

UIImage(CGImage: cgImage)