Skip to content

Commit e6f113c

Browse files
committed
feat: more publishing compatibility
1 parent 53c5f4a commit e6f113c

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
}
1212

1313
dependencies {
14-
implementation("com.github.ajalt.colormath:colormath:3.6.0")
14+
api("com.github.ajalt.colormath:colormath:3.6.0")
1515
}
1616

1717
tasks.test {

src/main/kotlin/me/aroze/colornames/ColorNames.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ class ColorNames(
1717
kdTree = buildKDTree(colorNames.map { Triple(it.lightness, it.aComponent, it.bComponent) to it }.toList(), 0)
1818
}
1919

20+
/**
21+
* Get the name of the closest color to the given hex color
22+
*/
23+
fun getName(hex: String): String {
24+
return findClosestColor(hex).name
25+
}
26+
27+
/**
28+
* Get the name of the closest color to the given RGB color
29+
*/
30+
fun getName(r: Int, g: Int, b: Int): String {
31+
return findClosestColor(r, g, b).name
32+
}
33+
34+
/**
35+
* Get the name of the closest color to the given [LAB] color
36+
*/
37+
fun getName(lab: LAB): String {
38+
return findClosestColor(lab).name
39+
}
40+
41+
2042
/**
2143
* Find the closest color to the given hex color
2244
*

0 commit comments

Comments
 (0)