Porygon is a library for generate low-poly style images. It's algorithm is based on this paper and Polyvia. The Delaunay algorithm used is this library.
如果你看的懂中文,你可以看我的这篇文章,里面会介绍实现的思路。
- Get the edge points
- Use Sobel to find the edge vertices and randomly take a few vertices
- Generate random vertices using Poisson samples
- Merge these vertices
- Use Delaunay to form a number of triangles
- Get the color from the center of the triangle and fill the color
- iOS 6.0+
- Xcode 7.0+
- Add
pod 'Porygon'
to your Podfile. - Run
pod install
orpod update
. - Import <Porygon/Porygon.h>.
- Download all the files in the Sources subdirectory.
- Add the source files to your Xcode project.
- Link with required frameworks:
- UIKit
- Import
DVSPorygon.h
.
DVSPorygon *porygon = [[DVSPorygon alloc] init];
UIImage * lowPolyImage = [porygon lowPolyWithImage:[UIImage imageNamed:@"camera"]]; // get low poly image
DVSPorygon *porygon = [[DVSPorygon alloc] init];
// edge vertex count
porygon.vertexCount = 10000;
// randomly add the number of vertices
porygon.randomCount = 200;
// show wireframe effects
porygon.isWireframe = true;
UIImage * lowPolyImage = [porygon lowPolyWithImage:[UIImage imageNamed:@"camera"]]; // get low poly image
Porygon is provided under the MIT license. See LICENSE file for details.