marinehero / ChopChop

Chop an image to as many quadrants as you like at compile time. Great for dynamic content, suitable for games and image processing. .

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ChopChop

Description

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.

Screenshots of Demo

### Demo 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

Installation

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.

How to use

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.

To-dos

  • Implement background processing within the package
  • Add more helper functions to the PKImageMatrixCropper
  • Write Tests

Roadmap

  • We are open to new and awesome ideas, contribute if you like! :)

Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create pull request

License

ChopChop is available under the MIT license.

About

Chop an image to as many quadrants as you like at compile time. Great for dynamic content, suitable for games and image processing. .

License:MIT License


Languages

Language:Swift 100.0%