package main import ( "fmt" "red-green/door" "strings" "time" ) //go:generate sh -c "font-util extract -f 'Amazon Cyan,Serpent,Unchained,Asylum,ArmageonRed,BrainDmgBlu,Boner,Descent,Remorse,Dungeon' ../TDFONTS.TDF ../TDFONTS2.TDF ../TDFONTS9.TDF > fonts.go" //go:generate sh -c "font-util extract -f Armageddon -c 7,1 -c 4,2 ../TDFONTS2.TDF > rgfont.go; sed -i 's/Armageddon/RedGreen/g' rgfont.go" func font_demo(d *door.Door) { var output []string var l int var centering string var center bool = false var now time.Time = time.Now() // I have checks here (but not all are complete), that verify the font // output doesn't exceed the size of the screen. d.WriteA(door.Clrscr, door.CRNL) // + door.CRNL + door.CRNL) var fac door.ColorFont = FontAmazonCyan() output, l = fac.Output(now.Format("Jan Mon")) // Size check: Is this too big for the screen? /* if l > door.Width { output, l = fac.Output("Jan") } */ if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(fmt.Sprintf("%s%s%s", centering, o, door.Reset), door.CRNL) } d.WriteA(door.CRNL) } var patch door.ColorMap = fac.Scan(6) // log.Printf("Patch: %#v\n", patch) fac.Modify(4, patch) output, l = fac.Output(now.Format("Monday")) if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(fmt.Sprintf("%s%s%s", centering, o, door.Reset), door.CRNL) } d.WriteA(door.CRNL) fac.Modify(1, patch) output, l = fac.Output(now.Format("January")) // 3:04:05 PM")) if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(fmt.Sprintf("%s%s%s", centering, o, door.Reset), door.CRNL) } d.WriteA(door.CRNL) press_a_key(d) // Anarchy Blue - no digits var fab door.ColorFont = FontSerpent() output, l = fab.Output("Date/Time:") if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } var unchain door.ColorFont = FontUnchained() now = time.Now() output, l = unchain.Output(now.Format("01/02/2006")) if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } output, l = unchain.Output(now.Format("3:04:05 PM")) if l > door.Width { output, l = unchain.Output("Meow") } center = true if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } press_a_key(d) var asylum door.ColorFont = FontAsylum() output, l = asylum.Output("Bugz ROCKS") if l > door.Width { output, l = asylum.Output("Aslym") } if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } var brain door.ColorFont = FontBrainDmgBlu() output, l = brain.Output("I'm so BLUE") if l > door.Width { output, l = brain.Output("Blue") } if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } var boner door.ColorFont = FontBoner() output, l = boner.Output("Welcome!") if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } press_a_key(d) var descent door.ColorFont = FontDescent() output, l = descent.Output("Meanwhile...") if l > door.Width { output, l = descent.Output("BUGZ") } if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } var remorse door.ColorFont = FontRemorse() output, l = remorse.Output("Enjoy the fonts") if l > door.Width { output, l = remorse.Output("Amazing") } if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } var dungeon door.ColorFont = FontDungeon() output, l = dungeon.Output("Until NEXT time") if l > door.Width { output, l = dungeon.Output("Beware") } if l < door.Width { if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } /* redgreen := FontArmageddon() white := redgreen.Scan(7) blue := redgreen.Scan(4) redgreen.Modify(1, white) redgreen.Modify(2, blue) */ redgreen := FontRedGreen() output, l = redgreen.Output("Red-Green") center = false if l < door.Width { press_a_key(d) // Don't center this if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) // Center this part (below the MemStat panel) output, l = redgreen.Output("Software") center = true if center { centering = strings.Repeat(" ", (door.Width-l)/2) } else { centering = "" } for _, o := range output { d.WriteA(centering, o, door.Reset, door.CRNL) } d.WriteA(door.CRNL) } }