File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
commons/src/main/kotlin/org/fossify/commons/extensions Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,14 @@ import kotlin.math.log10
1717import kotlin.math.pow
1818
1919fun Int.getContrastColor (): Int {
20- val luminance = ColorUtils .calculateLuminance(this )
21- return if (luminance > 0.5 ) DARK_GREY else Color .WHITE
20+ return getContrastColor(DARK_GREY , Color .WHITE )
21+ }
22+
23+ fun Int.getContrastColor (colorFirst : Int , colorSecond : Int ): Int {
24+ val contrastFirst = ColorUtils .calculateContrast(colorFirst, this )
25+ val contrastSecond = ColorUtils .calculateContrast(colorSecond, this )
26+
27+ return if (contrastFirst >= contrastSecond) colorFirst else colorSecond
2228}
2329
2430fun Int.toHex () = String .format(" #%06X" , 0xFFFFFF and this ).uppercase(Locale .getDefault())
You can’t perform that action at this time.
0 commit comments