diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-11-03 15:15:32 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-11-03 15:15:32 +0100 |
commit | d4d9ea0afaf76778f3bb588e501749867053ca5f (patch) | |
tree | f56fb614778ca074393bb5647244ba35be388dc9 /src/main/kotlin/pl/treksoft/kvision/utils | |
parent | 0bc8ff5a2d4b63d184d4289351d93195d8ef66bd (diff) | |
download | kvision-d4d9ea0afaf76778f3bb588e501749867053ca5f.tar.gz kvision-d4d9ea0afaf76778f3bb588e501749867053ca5f.tar.bz2 kvision-d4d9ea0afaf76778f3bb588e501749867053ca5f.zip |
Refactoring - simplified constructors
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/utils')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt index 9c88326b..e2396868 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt @@ -1,4 +1,5 @@ @file:Suppress("TooManyFunctions") + package pl.treksoft.kvision.utils import pl.treksoft.kvision.core.CssSize @@ -14,25 +15,22 @@ fun Int.cm(): CssSize = Pair(this, UNIT.cm) fun Int.mm(): CssSize = Pair(this, UNIT.mm) @Suppress("FunctionNaming") fun Int.`in`(): CssSize = Pair(this, UNIT.`in`) + fun Int.pc(): CssSize = Pair(this, UNIT.pc) fun Int.vh(): CssSize = Pair(this, UNIT.vh) fun Int.vw(): CssSize = Pair(this, UNIT.vw) fun Int.vmin(): CssSize = Pair(this, UNIT.vmin) fun Int.vmax(): CssSize = Pair(this, UNIT.vmax) -object Utils { +private val hex = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f") - private val hex = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f") - - @Suppress("MagicNumber") - fun intToHexString(n: Int): String { - var result = "" - var num = n - for (i in 0 until 6) { - result = hex[num and 0xF] + result - num = num shr 4 - } - return result +@Suppress("MagicNumber") +fun Int.toHexString(): String { + var result = "" + var num = this + for (i in 0 until 6) { + result = hex[num and 0xF] + result + num = num shr 4 } - + return result } |