Comments (6)
The following solves the bug:
The cropping method isn't really cropping, it adjusts to the size of the to: parameter whether it's larger or smaller than the input image.
CIConstantColorGenerator generates an image with size 0x0, so you need to apply the cropping method before returning it as output of the generate function. That means it needs to use the input image just like the other functions. The following generate function works without crashing in the Xcode 8.2.1 playground:
func generate(color: UIColor) -> Filter {
return { image in
let parameters = [kCIInputColorKey: CIColor(cgColor: color.cgColor)]
guard let filter = CIFilter(name: "CIConstantColorGenerator",
withInputParameters: parameters)
else { fatalError() }
guard let outputImage = filter.outputImage
else { fatalError() }
return outputImage.cropping(to: image.extent)
}
}
Btw the blur function returns an image larger than the input image, so it also needs cropping in the return statement. Once you have added cropping to all the other functions, cropping is no longer needed in the overlay function.
Also to avoid all the "failed to obtain sandbox extension" warning messages I added the following to the Xcode 8.2.1 playground:
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
from functional-swift.
Hi @hugofalkman, I remember we had this problem with old versions UIKit. Could you try on a recent version or on the Mac? It might also be a new problem, not sure!
from functional-swift.
Am on latest Xcode 8.2.1 so am sure it's a new problem. Just copy my code into a fresh Xcode playground to reproduce.
from functional-swift.
Thanks a lot @hugofalkman !
I'm going to leave this open until we have time to do a proper update of the book. That will also help other people stumbling over this issue.
from functional-swift.
This issue was closed, but I don't see an updated version of the book on Gumroad.
from functional-swift.
No, we're working on it =)
from functional-swift.
Related Issues (20)
- rename CollectionType.decompose into CollectionType.decomposed HOT 1
- Book revision in the book. HOT 2
- Wrong output in Theoretical Background: Currying HOT 1
- Ambiguous Issue HOT 1
- Swift 3 HOT 1
- About The book what name is Functional Swift first chapter HOT 2
- Syntax error in book
- Syntax error in book
- Syntax error In book
- Phrasing error in book
- Syntax error in book
- Syntax error in book
- Thinking Functionally - Example: the complicated canSafelyEngageShip(_:friendly:) function HOT 1
- Infinite loop in FileLinesIterator HOT 3
- error while calling colorGenerator HOT 5
- get error while call colorGenerator
- Hi,where is the playground? HOT 1
- Workaround for qsort intermediate let HOT 1
- Page 27: Sample code has `subtract` function, but text talks about `difference` function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functional-swift.