Skip to content

Commit

Permalink
feat: more publishing compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
UwUAroze committed Oct 26, 2024
1 parent 53c5f4a commit e6f113c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

dependencies {
implementation("com.github.ajalt.colormath:colormath:3.6.0")
api("com.github.ajalt.colormath:colormath:3.6.0")
}

tasks.test {
Expand Down
22 changes: 22 additions & 0 deletions src/main/kotlin/me/aroze/colornames/ColorNames.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ class ColorNames(
kdTree = buildKDTree(colorNames.map { Triple(it.lightness, it.aComponent, it.bComponent) to it }.toList(), 0)
}

/**
* Get the name of the closest color to the given hex color
*/
fun getName(hex: String): String {
return findClosestColor(hex).name
}

/**
* Get the name of the closest color to the given RGB color
*/
fun getName(r: Int, g: Int, b: Int): String {
return findClosestColor(r, g, b).name
}

/**
* Get the name of the closest color to the given [LAB] color
*/
fun getName(lab: LAB): String {
return findClosestColor(lab).name
}


/**
* Find the closest color to the given hex color
*
Expand Down

0 comments on commit e6f113c

Please sign in to comment.