Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 77 additions & 26 deletions Sources/VaporToolbox/Util/PrintUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,63 @@ func escapeshellarg(_ command: String) -> String {
}

private func printDroplet(on console: some Console) {
let asciiArt: [String] = [
" ",
" ** ",
" **~~** ",
" **~~~~~~** ",
" **~~~~~~~~~~** ",
" **~~~~~~~~~~~~~~** ",
" **~~~~~~~~~~~~~~~~~~** ",
" **~~~~~~~~~~~~~~~~~~~~~~** ",
" **~~~~~~~~~~~~~~~~~~~~~~~~** ",
" **~~~~~~~~~~~~~~~~~~~~~~~~~~** ",
"**~~~~~~~~~~~~~~~~~~~~~~~~~~~~**",
"**~~~~~~~~~~~~~~~~~~~~~~~~~~~~**",
"**~~~~~~~~~~~~~~~~~~~~~++++~~~**",
" **~~~~~~~~~~~~~~~~~~~++++~~~** ",
" ***~~~~~~~~~~~~~~~++++~~~*** ",
" ****~~~~~~~~~~++++~~**** ",
" *****~~~~~~~~~***** ",
" ************* ",
" ",
let dropletArt: [String] = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WAY too tall. The old one already took up almost half my usual terminal window. This is more than twice that height—which means it wouldn't even be completely visible at any given scroll position.

" ",
" == ",
" ====== ",
" ======== ",
" ========== ",
" ============== ",
" ================ ",
" ============== ",
" ",
" ++++ ++++ ",
" ++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++++ ",
" * ++++++++++++++++++++++++++++ * ",
" *** ++++++++++++++++++++ *** ",
" ****** ****** ",
" ************ ************ ",
" ********************************************** ",
" ********************************************** ",
" ********************************************** ",
" ******************************************** ",
" # **************************************** # ",
" #### ******************************** #### ",
" ###### ******************** ###### ",
" ########### ########### ",
" #################### #################### ",
" ######################################################## ",
" ######################################################## ",
" ###################################################### ",
" ################################################## ",
" ############################################ ",
" ++ ################################## ++ ",
" +++++ ############ +++++ ",
" ++++++++++ ++++++++++ ",
" ++++++++++++++++++++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++++++++ ",
" ++++++++++++++++++++++++++ ",
" ++++++++++++++++++ ",
" ",
]

let textArt: [String] = [
" _ __ ___ ___ ___ ",
#"\ \ / / /\ | |_) / / \ | |_) "#,
#" \_\/ /_/--\ |_| \_\_/ |_| \ "#,
" a server framework for Swift ",
" ",
]

let colors: [Character: ConsoleColor] = [
"*": .magenta,
"~": .blue,
"+": .cyan,
let textColors: [Character: ConsoleColor] = [
"_": .magenta,
"/": .magenta,
"\\": .magenta,
Expand All @@ -55,9 +81,34 @@ private func printDroplet(on console: some Console) {
")": .magenta,
]

for line in console.center(asciiArt) {
// `+` appears in both the upper ring (lines 9–16) and the lower ring (lines 33–43).
// Pick a threshold between those ranges so each ring gets its own color.
let lowerRingStart = 25
func dropletColor(for character: Character, lineIndex: Int) -> ConsoleColor? {
switch character {
case "=": .custom(r: 63, g: 184, b: 248)
case "+": lineIndex < lowerRingStart
? .custom(r: 74, g: 125, b: 232)
: .custom(r: 217, g: 79, b: 227)
case "*": .custom(r: 91, g: 90, b: 200)
case "#": .custom(r: 154, g: 85, b: 232)
default: nil
}
}

for (lineIndex, line) in console.center(dropletArt).enumerated() {
for character in line {
console.output(
String(character).consoleText(color: dropletColor(for: character, lineIndex: lineIndex)),
newLine: false
)
}
console.output("", style: .plain, newLine: true)
}

for line in console.center(textArt) {
for character in line {
console.output(String(character).consoleText(color: colors[character]), newLine: false)
console.output(String(character).consoleText(color: textColors[character]), newLine: false)
}
console.output("", style: .plain, newLine: true)
}
Expand Down
Loading