commit 8497b7811a35b273ad523ebd1dfe55c8a38307f7
parent 5ca82c7be8ff880e6ce16b5e64ab014392b9b187
Author: FIGBERT <figbert@figbert.com>
Date: Wed, 8 Dec 2021 11:04:38 -0800
Replace color demo with drawing of random pot
Diffstat:
A | art.go | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
M | main.go | | | 42 | ++++-------------------------------------- |
M | styles.go | | | 32 | ++++++++++++++++---------------- |
3 files changed, 58 insertions(+), 54 deletions(-)
diff --git a/art.go b/art.go
@@ -0,0 +1,38 @@
+package main
+
+import "strings"
+
+func base(baseType int) string {
+ var out strings.Builder
+
+ switch baseType {
+ case 0:
+ gray.Bold(true)
+ green.Bold(true)
+ bright_cyan.Bold(true)
+
+ out.WriteString(gray.Render(":"))
+ out.WriteString(green.Render("___________"))
+ out.WriteString(bright_cyan.Render("./~~~\\."))
+ out.WriteString(green.Render("___________"))
+ out.WriteString(gray.Render(":") + "\n")
+
+ out.WriteString(gray.Render(" \\ /") + "\n")
+ out.WriteString(gray.Render(" \\_________________________/") + "\n")
+ out.WriteString(gray.Render(" (_) (_)") + "\n")
+
+ gray.UnsetBold()
+ green.UnsetBold()
+ bright_cyan.UnsetBold()
+ case 1:
+ out.WriteString(gray.Render("("))
+ out.WriteString(green.Render("---"))
+ out.WriteString(bright_cyan.Render("./~~~\\."))
+ out.WriteString(green.Render("---"))
+ out.WriteString(gray.Render(")") + "\n")
+ out.WriteString(gray.Render(" ( )") + "\n")
+ out.WriteString(gray.Render(" (_________)") + "\n")
+ }
+
+ return out.String()
+}
diff --git a/main.go b/main.go
@@ -2,10 +2,10 @@ package main
import (
"log"
- "strings"
+ "math/rand"
+ "time"
tea "github.com/charmbracelet/bubbletea"
- gloss "github.com/charmbracelet/lipgloss"
)
type model struct{}
@@ -25,45 +25,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (m model) View() string {
- style := gloss.NewStyle().Foreground(black)
-
- var out strings.Builder
- out.WriteString(style.Render("a") + " ")
- style.Foreground(blue)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(green)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(cyan)
- out.WriteString(style.Render("a") + "\n")
- style.Foreground(red)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(magenta)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(brown)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(light_gray)
- out.WriteString(style.Render("a") + "\n")
- style.Foreground(gray)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(bright_blue)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(bright_green)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(bright_cyan)
- out.WriteString(style.Render("a") + "\n")
- style.Foreground(bright_red)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(bright_magenta)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(yellow)
- out.WriteString(style.Render("a") + " ")
- style.Foreground(bright_white)
- out.WriteString(style.Render("a") + " ")
-
- return out.String()
+ return base(rand.Intn(2))
}
func main() {
+ rand.Seed(time.Now().UnixNano())
if err := tea.NewProgram(model{}).Start(); err != nil {
log.Fatal(err)
}
diff --git a/styles.go b/styles.go
@@ -2,19 +2,19 @@ package main
import gloss "github.com/charmbracelet/lipgloss"
-var black = gloss.Color("0")
-var blue = gloss.Color("1")
-var green = gloss.Color("2")
-var cyan = gloss.Color("3")
-var red = gloss.Color("4")
-var magenta = gloss.Color("5")
-var brown = gloss.Color("6")
-var light_gray = gloss.Color("7")
-var gray = gloss.Color("8")
-var bright_blue = gloss.Color("9")
-var bright_green = gloss.Color("10")
-var bright_cyan = gloss.Color("11")
-var bright_red = gloss.Color("12")
-var bright_magenta = gloss.Color("13")
-var yellow = gloss.Color("14")
-var bright_white = gloss.Color("15")
+var black = gloss.NewStyle().Foreground(gloss.Color("0"))
+var blue = gloss.NewStyle().Foreground(gloss.Color("1"))
+var green = gloss.NewStyle().Foreground(gloss.Color("2"))
+var cyan = gloss.NewStyle().Foreground(gloss.Color("3"))
+var red = gloss.NewStyle().Foreground(gloss.Color("4"))
+var magenta = gloss.NewStyle().Foreground(gloss.Color("5"))
+var brown = gloss.NewStyle().Foreground(gloss.Color("6"))
+var light_gray = gloss.NewStyle().Foreground(gloss.Color("7"))
+var gray = gloss.NewStyle().Foreground(gloss.Color("8"))
+var bright_blue = gloss.NewStyle().Foreground(gloss.Color("9"))
+var bright_green = gloss.NewStyle().Foreground(gloss.Color("10"))
+var bright_cyan = gloss.NewStyle().Foreground(gloss.Color("11"))
+var bright_red = gloss.NewStyle().Foreground(gloss.Color("12"))
+var bright_magenta = gloss.NewStyle().Foreground(gloss.Color("13"))
+var yellow = gloss.NewStyle().Foreground(gloss.Color("14"))
+var bright_white = gloss.NewStyle().Foreground(gloss.Color("15"))