Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyome22/legoartswift
Generates an image that looks like LEGO Art.
https://github.com/kyome22/legoartswift
Last synced: 3 months ago
JSON representation
Generates an image that looks like LEGO Art.
- Host: GitHub
- URL: https://github.com/kyome22/legoartswift
- Owner: Kyome22
- Created: 2021-10-10T14:19:53.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-10T11:55:51.000Z (about 1 year ago)
- Last Synced: 2023-12-10T12:38:59.686Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 25 MB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LegoArtSwift
Provides utilities to create your own LEGO Art.
## LegoArtFilter
Generates an image that looks like LEGO Art.
This library supports both iOS (14+) and macOS (11+).### Usage
```swift
// Get CGImage from CIImage
let input = CIImage()
if let legoArtFilter = LegoArtFilter(ciImage: input) {
let output = legoArtFilter.exportCGImage()
}// Get UIImage from UIImage
let input = UIImage()
if let legoArtFilter = LegoArtFilter(from: input) {
let output = legoArtFilter.exportUIImage()
}// Get NSImage from NSImage
let input = NSImage()
if let legoArtFilter = LegoArtFilter(from: input) {
let output = legoArtFilter.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 legoArtFilter = LegoArtFilter(ciImage: CIImage,
baseColor: CGColor,
studType: StudType,
maxStud: Int,
studPixelWidth: Int)
```### Demo
`LegoArtSwiftDemo.xcodeproj` is a demonstration of LegoArtFilter in the Examples directory.
You can build it Xcode.app (ver 13+).#### iOS
#### macOS
## LegoColors
A library to make it easier to handle the colors of LEGO blocks with Swift.
This library supports both iOS (14+) and macOS (11+).### Usage
```swift
// Get CGColor from name of a brick.
let color = LegoColor.darkTurquoise.color// Get an approximate LegoColor from CGColor
let cgColor = CGColor(srgbRed: 0.12, green: 0.34, blue: 0.56, alpha: 1.0)
let legoColor = LegoColor(cgColor: cgColor)// Get an approximate LegoColor from UIColor or NSColor.
let legoColor = LegoColor(uiColor: UIColor.blue)
let legoColor = LegoColor(nsColor: NSColor.yellow)
```Note: `LegoColor` refers to [Color Guid of Bricklink](https://www.bricklink.com/catalogColors.asp).
## LICENSE
Copyright (c) 2021 Takuto NAKAMURA (Kyome)
You are free to use it as long as it is not for commercial use.