bricklife / LegoArtFilter

Generates an image that looks like LEGO Art.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LegoArtFilter

Generates an image that looks like LEGO Art.
This library supports both iOS (14≤) and macOS (11≤).

Usage

// Get CGImage from CIImage
let input = CIImage()
if let legoArt = LegoArt(ciImage: input) {
    let output = legoArt.exportCGImage()
}

// Get UIImage from UIImage
let input = UIImage()
if let legoArt = LegoArt(from: input) {
    let output = legoArt.exportUIImage()
}

// Get NSImage from NSImage
let input = NSImage()
if let legoArt = LegoArt(from: input) {
    let output = legoArt.exportNSImage()
}

// Use the options
// baseColor:      It is used as a base for transparent images such as PNG.
// StudType:       It is reflected in the appearance of the brick.
//                 (round/round plate/square/square plate)
// maxStud:        Determines the maximum bricks number of the generated image.
// studPixelWidth: Specifies the pixel width of the actual brick to be drawn.
let legoArt = LegoArt(ciImage: CIImage,
                      baseColor: CGColor,
                      studType: StudType,
                      maxStud: Int,
                      studPixelWidth: Int)

Demo

Demonstration of LegoArtFilter in the Examples directory.

iOS

macOS

LICENSE

Copyright (c) 2021 Takuto NAKAMURA (Kyome)

You are free to use it as long as it is not for commercial use.

About

Generates an image that looks like LEGO Art.


Languages

Language:Swift 100.0%