Chop an image to as many quadrants as you like at compile time. Suitable for games and image processing.
Great for dynamic content, s
Here's what you can do with this package:
- You can crop an image into a square
- You can crop an image into as many quadrants as you like, by specifying the number of rows and columns, a matrix.
A demo is available which allows you:
- to pick an image,
- specify your matrix
- and view your chopped up image into a nice collection view
There isn't a cocoapod for this package as of today, didn't have the time to do so just yet. For now, simply dragging the single source file into your project is all that's required.
You simply have an instance of a UIImage you loaded yourself, from somewhere, anywhere:
var myImage = UIImage(imageNamed:"maybe from the assets, or the image picker class")
Define and instantiate an array which will hold your cropped UIImages
var images = [UIImage]()
You can either crop your image into a nice square
var profileImageView.image = myImage.cropToSquare()
Or if you want to make a game or something and require your images to be cropped up into equal quadrants then simply pass a matrix into the cropWithMatrix method. You need to insert a tuple which consists of two ints which are attributed to rows and columns.
let rowsNum = 2
let colsNum = 2
images = image.cropWithMatrix((rowsNum, colsNum))
You'll then get your very own images array which contains your cropped/chopped up image.
- Implement background processing within the package
- Add more helper functions to the PKImageMatrixCropper
- Write Tests
- We are open to new and awesome ideas, contribute if you like! :)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create pull request
ChopChop is available under the MIT license.