Latest 1.1.2
Homepage https://github.com/bmaslakov/cocoa-close-pixelate
License MIT
Platforms ios 9.0, requires ARC
Authors

cocoa-close-pixelate

License: MIT [Bintray]()

This simple library allows you to easily create and combine various pixelation effects.

Based on a wonderful script by David DeSandro: close-pixelate.desandro.com.

You may be also be interested in the Android/Java version of the library.

Examples

Officer-old Officer-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.diamond, resolution: 48, size: 50),
                        PixelateLayer(.diamond, resolution: 48, offset: 24),
                        PixelateLayer(.diamond, resolution: 8, size: 6))
Stanley-old Stanley-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.square, resolution: 32),
                        PixelateLayer(.circle, resolution: 32, offset: 15),
                        PixelateLayer(.circle, resolution: 32, size: 26, offset: 13),
                        PixelateLayer(.circle, resolution: 32, size: 18, offset: 10),
                        PixelateLayer(.circle, resolution: 32, size: 12, offset: 8))
Stanley-old Stanley-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.square, resolution: 48),
                        PixelateLayer(.diamond, resolution: 48, offset: 12, alpha: 0.5),
                        PixelateLayer(.diamond, resolution: 48, offset: 36, alpha: 0.5),
                        PixelateLayer(.diamond, resolution: 16, size: 8, offset: 4))
Tony-old Tony-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.circle, resolution: 32, size: 6, offset: 8),
                        PixelateLayer(.circle, resolution: 32, size: 9, offset: 8),
                        PixelateLayer(.circle, resolution: 32, size: 12, offset: 24),
                        PixelateLayer(.circle, resolution: 32, size: 9, offset: 0))
Wonder-old Wonder-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.diamond, resolution: 24, size: 25),
                        PixelateLayer(.diamond, resolution: 24, offset: 12),
                        PixelateLayer(.square, resolution: 24, alpha: 0.6))
Anita-old Anita-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.square, resolution: 32),
                        PixelateLayer(.circle, resolution: 32, offset: 16),
                        PixelateLayer(.circle, resolution: 32, offset: 0, alpha: 0.5),
                        PixelateLayer(.circle, resolution: 16, size: 9, offset: 0, alpha: 0.5))
Giraffe-old Giraffe-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.circle, resolution: 24),
                        PixelateLayer(.circle, resolution: 24, size: 9, offset: 12))
Kendra-old Kendra-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.square, resolution: 48, offset: 12),
                        PixelateLayer(.circle, resolution: 48, offset: 0),
                        PixelateLayer(.diamond, resolution: 16, size: 15, offset: 0, alpha: 0.6),
                        PixelateLayer(.diamond, resolution: 16, size: 15, offset: 8, alpha: 0.6))
Gavin-old Gavin-new
Pixelate.create(pixels: bitmap,
                layers: PixelateLayer(.square, resolution: 48),
                        PixelateLayer(.diamond, resolution: 12, size: 8),
                        PixelateLayer(.diamond, resolution: 12, size: 8, offset: 6))

Download

The library is available via cocoapods:

pod 'ClosePixelate', '1.1.2'

Usage

There are several Pixelate.create* methods in the
Pixelate
class, allowing to create a pixelated bitmap from CGImage:

let pixelated = Pixelate.create(pixels: bitmap,
                                layers: PixelateLayer(.square, resolution: 48),
                                        PixelateLayer(.diamond, resolution: 48, offset: 12, alpha: 0.5),
                                        PixelateLayer(.diamond, resolution: 48, offset: 36, alpha: 0.5),
                                        PixelateLayer(.diamond, resolution: 16, size: 8, offset: 4))

You also can draw directly on a bitmap or on a canvas, using Pixelate.render* methods.

There are three basic layer types:

Original Square Diamond Circle
jamie simple-lo-square simple-lo-diamond simple-lo-circle

You can change size, resolution, offset and alpha parameters of each layer:

resolution = 10 resolution = 25 resolution = 20, size = 50, alpha = 0.5
simple-lo-square simple-hi-square jamie-new

You can also combine several layers into one image:

square, resolution = 25 diamond, resolution = 10
simple-hi-square + simple-lo-diamond = sample-multilayer

Latest podspec

{
    "name": "ClosePixelate",
    "version": "1.1.2",
    "summary": "Cocoa port of https://github.com/desandro/close-pixelate",
    "homepage": "https://github.com/bmaslakov/cocoa-close-pixelate",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "bmaslakov": "[email protected]"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/bmaslakov/cocoa-close-pixelate.git",
        "tag": "1.1.2"
    },
    "source_files": "ClosePixelate/ClosePixelate/*.swift",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This