mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-05-06 20:29:52 -07:00
Ascii art.
This commit is contained in:
parent
6143ada860
commit
fa1e2d76ba
4 changed files with 56 additions and 53 deletions
53
src/main/kotlin/com/beust/kobalt/AsciiArt.kt
Normal file
53
src/main/kotlin/com/beust/kobalt/AsciiArt.kt
Normal file
|
@ -0,0 +1,53 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.kobalt.misc.log
|
||||
import java.util.*
|
||||
|
||||
|
||||
class AsciiArt {
|
||||
companion object {
|
||||
private val BANNERS = arrayOf(
|
||||
" __ __ __ __ __ \n" +
|
||||
" / //_/ ____ / /_ ____ _ / / / /_\n" +
|
||||
" / ,< / __ \\ / __ \\ / __ `/ / / / __/\n" +
|
||||
" / /| | / /_/ / / /_/ // /_/ / / / / /_ \n" +
|
||||
" /_/ |_| \\____/ /_.___/ \\__,_/ /_/ \\__/ ",
|
||||
|
||||
" _ __ _ _ _ \n" +
|
||||
" | |/ / ___ | |__ __ _ | | | |_ \n" +
|
||||
" | ' / / _ \\ | '_ \\ / _` | | | | __|\n" +
|
||||
" | . \\ | (_) | | |_) | | (_| | | | | |_ \n" +
|
||||
" |_|\\_\\ \\___/ |_.__/ \\__,_| |_| \\__| "
|
||||
)
|
||||
|
||||
val banner : String get() = BANNERS.get(Random().nextInt(BANNERS.size()))
|
||||
|
||||
fun box(s: String) : List<String> {
|
||||
val ul = "\u2554"
|
||||
val ur = "\u2557"
|
||||
val h = "\u2550"
|
||||
val v = "\u2551"
|
||||
val bl = "\u255a"
|
||||
val br = "\u255d"
|
||||
|
||||
fun r(n: Int, w: String) : String {
|
||||
with(StringBuffer()) {
|
||||
repeat(n, { append(w) })
|
||||
return toString()
|
||||
}
|
||||
}
|
||||
|
||||
return arrayListOf(
|
||||
ul + r(s.length() + 2, h) + ur,
|
||||
"$v $s $v",
|
||||
bl + r(s.length() + 2, h) + br)
|
||||
}
|
||||
|
||||
fun logBox(s: String) {
|
||||
box(s).forEach {
|
||||
log(1, " $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue