Skip to content

Conversation

@ktiays
Copy link
Member

@ktiays ktiays commented Oct 23, 2022

No description provided.

Copy link
Member

@unixzii unixzii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great but there are some small issues need to be solved before a merge.

@@ -0,0 +1,41 @@
//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we use Image+Color.swift as the file name to imply that this is an extension?

extension UIImage {

@inlinable
public func dominantColors(clusterCount: Int = 5) -> [UIColor] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a PlatformImage typealias to unify these APIs.

extension CIImage {

public func dominantColor(clusterCount: Int = 5) -> [PlatformColor] {
guard let kMeansFilter = CIFilter(name: "CIKMeans") else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The k prefix is for constants I believe, we should just remove it.

var dominantColors = [PlatformColor]()

for i in 0..<clusterCount {
let color = PlatformColor(red: CGFloat(bitmap[i * 4 + 0]) / 255.0, green: CGFloat(bitmap[i * 4 + 1]) / 255.0, blue: CGFloat(bitmap[i * 4 + 2]) / 255.0, alpha: CGFloat(bitmap[i * 4 + 3]) / 255.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some line breaks would be nice to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants