Skip to content

Commit

Permalink
Merge pull request #35 from imclerran/ascii-roc
Browse files Browse the repository at this point in the history
Improved splash screen
  • Loading branch information
imclerran authored Jun 16, 2024
2 parents 0a5c7d7 + b7eeb91 commit c59c768
Show file tree
Hide file tree
Showing 2 changed files with 291 additions and 12 deletions.
243 changes: 243 additions & 0 deletions src/AsciiArt.roc
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
module [Art, size, width, height, rocStart, rocSmall, rocLarge, rocStartColored, rocLargeColored, rocSmallColored]

import ansi.Core

Art : {
height : I32,
width : I32,
art : List { text : Str, r : I32, c : I32, color : Core.Color },
}

size : List Str -> { width : I32, height : I32 }
size = \art -> {
width: width art,
height: height art,
}

height : List Str -> I32
height = \art -> List.len art |> Num.toI32

width : List Str -> I32
width = \art -> List.first art |> Result.withDefault "" |> Str.countUtf8Bytes |> Num.toI32

rocStart = [
" _ _ ",
" _ __ ___ ___ ____| |_ __ _ _ __| |_ ",
"| '__/ _ \\ / __|____/ ___| __/ _` | '__| __|",
"| | | (_) | (_|_____\\___ \\ || (_| | | | |_ ",
"|_| \\___/ \\___| |____/\\__\\__,_|_| \\__|",
" quick start cli ",
]

rocStartColored = {
width: 45,
height: 6,
art: [
{ text: "_", r: 0, c: 26, color: B8 93 },
{ text: "_", r: 0, c: 40, color: B8 93 },
{ text: "_", r: 1, c: 1, color: B8 93 },
{ text: "__", r: 1, c: 3, color: B8 93 },
{ text: "___", r: 1, c: 6, color: B8 93 },
{ text: "___", r: 1, c: 12, color: B8 93 },
{ text: "____| |_ __ _ _ __| |_", r: 1, c: 21, color: B8 93 },
{ text: "| '__/ _ \\ / __|", r: 2, c: 0, color: B8 93 },
{ text: "____", r: 2, c: 16, color: B8 177 },
{ text: "/ ___| __/ _` | '__| __|", r: 2, c: 20, color: B8 93 },
{ text: "| | | (_) | (_", r: 3, c: 0, color: B8 93 },
{ text: "|_____", r: 3, c: 14, color: B8 177 },
{ text: "\\___ \\ || (_| | | | |_", r: 3, c: 20, color: B8 93 },
{ text: "|_| \\___/ \\___|", r: 4, c: 0, color: B8 93 },
{ text: "|____/\\__\\__,_|_| \\__|", r: 4, c: 20, color: B8 93 },
]
}

rocSmall = [
"___ ",
"\\ ---___ ",
" \\ ---___ ",
" \\ |\\ ",
" \\ | \\ __-\\ ",
" \\ | \\--' /_\\ ",
" \\ | \\ / ",
" \\|---______\\ ",
" /| __/ ",
" | | __/ ",
" | |_/ ",
" / | ",
" | | ",
" | _/ ",
" |/ ",
]

rocSmallColored = {
width: 31,
height: 15,
art: [
{ text: "___", r: 0, c: 0, color: B8 177 },
{ text: "\\ ---___", r: 1, c: 0, color: B8 177 },
{ text: "\\ ---___", r: 2, c: 2, color: B8 177 },
{ text: "\\ ", r: 3, c: 4, color: B8 177 },
{ text: "|\\", r: 3, c: 14, color: B8 93 },
{ text: "\\ ", r: 4, c: 6, color: B8 177 },
{ text: "| \\", r: 4, c: 14, color: B8 93 },
{ text: "__-", r: 4, c: 23, color: B8 177 },
{ text: "\\", r: 4, c: 26, color: B8 93 },
{ text: "\\ ", r: 5, c: 8, color: B8 177 },
{ text: "| \\", r: 5, c: 13, color: B8 93 },
{ text: "--' /", r: 5, c: 20, color: B8 177 },
{ text: "_\\", r: 5, c: 26, color: B8 93 },
{ text: "\\ ", r: 6, c: 10, color: B8 177 },
{ text: "| \\", r: 6, c: 13, color: B8 93 },
{ text: " /", r: 6, c: 22, color: B8 177 },
{ text: "\\", r: 7, c: 12, color: B8 177 },
{ text: "|---______\\", r: 7, c: 13, color: B8 93 },
{ text: "/|", r: 8, c: 12, color: B8 93 },
{ text: " __/", r: 8, c: 14, color: B8 177 },
{ text: "| |", r: 9, c: 11, color: B8 93 },
{ text: " __/", r: 9, c: 14, color: B8 177 },
{ text: "| |", r: 10, c: 11, color: B8 93 },
{ text: "_/", r: 10, c: 15, color: B8 177 },
{ text: "/ |", r: 11, c: 11, color: B8 93 },
{ text: "| |", r: 12, c: 10, color: B8 93 },
{ text: "| _/", r: 13, c: 10, color: B8 93 },
{ text: "|/", r: 14, c: 10, color: B8 93 },
]
}

rocLarge = [
"............ ",
" ............................ ",
" .................................... ",
" ..................................-- ",
" ................................---- ",
" ..............................------ ",
" ............................------- ",
" .........................--------- ",
" .......................----------- ",
" .....................------------- ",
" ..................-------------- ",
" ................:---------------- ",
" .............:------------------ ",
" ...........:-------------------- ......- ",
" .........:---------------------- ...........:--- ",
" .......:----------------------..............------ ",
" ....:------------------------............------- ",
" ..:--------------------------.........--------- ",
" .........:--------------------....... ",
" -....................:----------.... ",
" --..............................:--.. ",
" ---................................. ",
" ---.............................. ",
" ----:.......................... ",
" -----....................... ",
" ------.................... ",
" -------................ ",
" --------............. ",
" --------:......... ",
" ----------...... ",
" ----------.... ",
" ------------ ",
" ------------- ",
" ------------- ",
" -------------- ",
" --------------- ",
" -------------- ",
" ------------ ",
" --------- ",
" ------- ",
" ----- ",
" --- ",
]

rocLargeColored : Art
rocLargeColored = {
width: 94,
height: 42,
art: [
{ text: "............", r: 0, c: 0, color: B8 177 },
{ text: "............................", r: 1, c: 2, color: B8 177 },
{ text: "....................................", r: 2, c: 5, color: B8 177 },
{ text: "..................................", r: 3, c: 7, color: B8 177 },
{ text: "--", r: 3, c: 41, color: B8 93 },
{ text: "................................", r: 4, c: 9, color: B8 177 },
{ text: "----", r: 4, c: 41, color: B8 93 },
{ text: "..............................", r: 5, c: 11, color: B8 177 },
{ text: "------", r: 5, c: 41, color: B8 93 },
{ text: "............................", r: 6, c: 13, color: B8 177 },
{ text: "-------", r: 6, c: 41, color: B8 93 },
{ text: ".........................", r: 7, c: 16, color: B8 177 },
{ text: "---------", r: 7, c: 41, color: B8 93 },
{ text: ".......................", r: 8, c: 18, color: B8 177 },
{ text: "-----------", r: 8, c: 41, color: B8 93 },
{ text: ".....................", r: 9, c: 20, color: B8 177 },
{ text: "-------------", r: 9, c: 41, color: B8 93 },
{ text: "..................", r: 10, c: 23, color: B8 177 },
{ text: "--------------", r: 10, c: 41, color: B8 93 },
{ text: "...............", r: 11, c: 25, color: B8 177 },
{ text: ":----------------", r: 11, c: 40, color: B8 93 },
{ text: ".............", r: 12, c: 27, color: B8 177 },
{ text: ":------------------", r: 12, c: 40, color: B8 93 },
{ text: "...........", r: 13, c: 29, color: B8 177 },
{ text: ":--------------------", r: 13, c: 40, color: B8 93 },
{ text: "......", r: 13, c: 72, color: B8 177 },
{ text: "-", r: 13, c: 78, color: B8 93 },
{ text: ".........", r: 14, c: 31, color: B8 177 },
{ text: ":----------------------", r: 14, c: 40, color: B8 93 },
{ text: "...........", r: 14, c: 66, color: B8 177 },
{ text: ":---", r: 14, c: 77, color: B8 93 },
{ text: ".......", r: 15, c: 33, color: B8 177 },
{ text: ":----------------------", r: 15, c: 40, color: B8 93 },
{ text: "..............", r: 15, c: 63, color: B8 177 },
{ text: "------", r: 15, c: 77, color: B8 93 },
{ text: "....", r: 16, c: 36, color: B8 177 },
{ text: ":------------------------", r: 16, c: 40, color: B8 93 },
{ text: "............", r: 16, c: 65, color: B8 177 },
{ text: "-------", r: 16, c: 77, color: B8 93},
{ text: "..", r: 17, c: 38, color: B8 177 },
{ text: ":--------------------------", r: 17, c: 40, color: B8 93 },
{ text: ".........", r: 17, c: 67, color: B8 177 },
{ text: "---------", r: 17, c: 76, color: B8 93 },
{ text: ".........", r: 18, c: 39, color: B8 177 },
{ text: ":--------------------", r: 18, c: 48, color: B8 93 },
{ text: ".......", r: 18, c: 69, color: B8 177 },
{ text: "-", r: 19, c: 39, color: B8 93 },
{ text: "....................", r: 19, c: 40, color: B8 177 },
{ text: ":----------", r: 19, c: 60, color: B8 93 },
{ text: "....", r: 19, c: 71, color: B8 177 },
{ text: "--", r: 20, c: 38, color: B8 93 },
{ text: "..............................", r: 20, c: 40, color: B8 177 },
{ text: ":--", r: 20, c: 70, color: B8 93 },
{ text: "..", r: 20, c: 73, color: B8 177 },
{ text: "---", r: 21, c: 38, color: B8 93 },
{ text: ".................................", r: 21, c: 41, color: B8 177 },
{ text: "---", r: 22, c: 38, color: B8 93 },
{ text: "..............................", r: 22, c: 41, color: B8 177 },
{ text: "----:", r: 23, c: 37, color: B8 93 },
{ text: "..........................", r: 23, c: 42, color: B8 177 },
{ text: "-----", r: 24, c: 37, color: B8 93 },
{ text: ".......................", r: 24, c: 42, color: B8 177 },
{ text: "------", r: 25, c: 36, color: B8 93 },
{ text: "....................", r: 25, c: 42, color: B8 177 },
{ text: "-------", r: 26, c: 36, color: B8 93 },
{ text: "................", r: 26, c: 43, color: B8 177 },
{ text: "--------", r: 27, c: 35, color: B8 93 },
{ text: ".............", r: 27, c: 43, color: B8 177 },
{ text: "--------", r: 28, c: 35, color: B8 93 },
{ text: ":.........", r: 28, c: 43, color: B8 177 },
{ text: "----------", r: 29, c: 34, color: B8 93 },
{ text: "......", r: 29, c: 44, color: B8 177 },
{ text: "----------", r: 30, c: 34, color: B8 93 },
{ text: "....", r: 30, c: 44, color: B8 177 },
{ text: "------------", r: 31, c: 33, color: B8 93 },
{ text: "-------------", r: 32, c: 33, color: B8 93 },
{ text: "-------------", r: 33, c: 33, color: B8 93 },
{ text: "--------------", r: 34, c: 33, color: B8 93 },
{ text: "---------------", r: 35, c: 32, color: B8 93 },
{ text: "--------------", r: 36, c: 32, color: B8 93 },
{ text: "------------", r: 37, c: 31, color: B8 93 },
{ text: "---------", r: 38, c: 31, color: B8 93 },
{ text: "-------", r: 39, c: 30, color: B8 93 },
{ text: "-----", r: 40, c: 30, color: B8 93 },
{ text: "---", r: 41, c: 29, color: B8 93 },
],
}
60 changes: 48 additions & 12 deletions src/View.roc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module [renderInputAppName, renderPlatformSelect, renderPackageSelect, renderSearch, renderConfirmation, renderSplash, renderBox]

import AsciiArt
import BoxStyle exposing [BoxStyle, border]
import Controller exposing [UserAction]
import Model exposing [Model]
Expand Down Expand Up @@ -253,22 +254,57 @@ renderMultipleChoiceMenu = \model ->

renderSplash : Model -> List Core.DrawFn
renderSplash = \model ->
splashWidth = 45
splashHeight = 6
startRow = (model.screen.height - splashHeight) // 2
startCol = (model.screen.width - splashWidth) // 2
List.join [
[
renderExitPrompt model.screen,
renderControlsPrompt (controlsPromptStr model) model.screen,
],
renderOuterBorder model.screen,
[
Core.drawText " _ _ " { r: startRow, c: startCol, fg: Standard Magenta },
Core.drawText " _ __ ___ ___ ____| |_ __ _ _ __| |_ " { r: startRow + 1, c: startCol, fg: Standard Magenta },
Core.drawText "| '__/ _ \\ / __|____/ ___| __/ _` | '__| __|" { r: startRow + 2, c: startCol, fg: Standard Magenta },
Core.drawText "| | | (_) | (_|_____\\___ \\ || (_| | | | |_ " { r: startRow + 3, c: startCol, fg: Standard Magenta },
Core.drawText "|_| \\___/ \\___| |____/\\__\\__,_|_| \\__|" { r: startRow + 4, c: startCol, fg: Standard Magenta },
Core.drawText " quick start cli fast/friendly/functional" { r: startRow + 5, c: startCol, fg: Standard Cyan },
],

renderSplashBySize model.screen,
]

renderSplashBySize : Core.ScreenSize -> List Core.DrawFn
renderSplashBySize = \screen ->
art = chooseSplashArt screen
startRow = (screen.height - art.height) // 2
startCol = (screen.width - art.width) // 2
List.join [
renderArtAccent art screen,
renderAsciiArt art startRow startCol,
]

renderAsciiArt : AsciiArt.Art, I32, I32 -> List Core.DrawFn
renderAsciiArt = \art, startRow, startCol ->
List.map art.art \elem ->
Core.drawText elem.text { r: startRow + elem.r, c: startCol + elem.c, fg: elem.color }

chooseSplashArt : Core.ScreenSize -> AsciiArt.Art
chooseSplashArt = \screen ->
if
(screen.height >= (AsciiArt.rocLargeColored.height + 2))
&& (screen.width >= (AsciiArt.rocLargeColored.width + 2))
then
AsciiArt.rocLargeColored
else if
(screen.height >= (AsciiArt.rocSmallColored.height + 2))
&& (screen.width >= (AsciiArt.rocSmallColored.width + 2))
then
AsciiArt.rocSmallColored
else
AsciiArt.rocStartColored

renderArtAccent : AsciiArt.Art, Core.ScreenSize -> List Core.DrawFn
renderArtAccent = \art, screen ->
startRow = (screen.height - art.height) // 2
startCol = (screen.width - art.width) // 2
if art == AsciiArt.rocLargeColored then
List.mapWithIndex AsciiArt.rocStart \line, idx ->
Core.drawText line { r: startRow + 30 + Num.toI32 idx, c: startCol + 50, fg: Standard Cyan }
else if art == AsciiArt.rocSmallColored then
[
Core.drawText "roc start" { r: startRow + 11, c: startCol + 16, fg: Standard Cyan },
Core.drawText "quick start cli" { r: startRow + 12, c: startCol + 16, fg: Standard Cyan },
]
else
[Core.drawText " quick start cli" { r: startRow + 5, c: startCol, fg: Standard Cyan }]

0 comments on commit c59c768

Please sign in to comment.