fontdemo.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. package main
  2. import (
  3. "fmt"
  4. "red-green/door"
  5. "strings"
  6. "time"
  7. )
  8. //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"
  9. //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"
  10. func font_demo(d *door.Door) {
  11. var output []string
  12. var l int
  13. var centering string
  14. var center bool = false
  15. var now time.Time = time.Now()
  16. // I have checks here (but not all are complete), that verify the font
  17. // output doesn't exceed the size of the screen.
  18. d.WriteA(door.Clrscr, door.CRNL) // + door.CRNL + door.CRNL)
  19. var fac door.ColorFont = FontAmazonCyan()
  20. output, l = fac.Output(now.Format("Jan Mon"))
  21. // Size check: Is this too big for the screen?
  22. /*
  23. if l > door.Width {
  24. output, l = fac.Output("Jan")
  25. }
  26. */
  27. if l < door.Width {
  28. if center {
  29. centering = strings.Repeat(" ", (door.Width-l)/2)
  30. } else {
  31. centering = ""
  32. }
  33. for _, o := range output {
  34. d.WriteA(fmt.Sprintf("%s%s%s", centering, o, door.Reset), door.CRNL)
  35. }
  36. d.WriteA(door.CRNL)
  37. }
  38. var patch door.ColorMap = fac.Scan(6)
  39. // log.Printf("Patch: %#v\n", patch)
  40. fac.Modify(4, patch)
  41. output, l = fac.Output(now.Format("Monday"))
  42. if center {
  43. centering = strings.Repeat(" ", (door.Width-l)/2)
  44. } else {
  45. centering = ""
  46. }
  47. for _, o := range output {
  48. d.WriteA(fmt.Sprintf("%s%s%s", centering, o, door.Reset), door.CRNL)
  49. }
  50. d.WriteA(door.CRNL)
  51. fac.Modify(1, patch)
  52. output, l = fac.Output(now.Format("January")) // 3:04:05 PM"))
  53. if center {
  54. centering = strings.Repeat(" ", (door.Width-l)/2)
  55. } else {
  56. centering = ""
  57. }
  58. for _, o := range output {
  59. d.WriteA(fmt.Sprintf("%s%s%s", centering, o, door.Reset), door.CRNL)
  60. }
  61. d.WriteA(door.CRNL)
  62. press_a_key(d)
  63. // Anarchy Blue - no digits
  64. var fab door.ColorFont = FontSerpent()
  65. output, l = fab.Output("Date/Time:")
  66. if l < door.Width {
  67. if center {
  68. centering = strings.Repeat(" ", (door.Width-l)/2)
  69. } else {
  70. centering = ""
  71. }
  72. for _, o := range output {
  73. d.WriteA(centering, o, door.Reset, door.CRNL)
  74. }
  75. d.WriteA(door.CRNL)
  76. }
  77. var unchain door.ColorFont = FontUnchained()
  78. now = time.Now()
  79. output, l = unchain.Output(now.Format("01/02/2006"))
  80. if l < door.Width {
  81. if center {
  82. centering = strings.Repeat(" ", (door.Width-l)/2)
  83. } else {
  84. centering = ""
  85. }
  86. for _, o := range output {
  87. d.WriteA(centering, o, door.Reset, door.CRNL)
  88. }
  89. d.WriteA(door.CRNL)
  90. }
  91. output, l = unchain.Output(now.Format("3:04:05 PM"))
  92. if l > door.Width {
  93. output, l = unchain.Output("Meow")
  94. }
  95. center = true
  96. if l < door.Width {
  97. if center {
  98. centering = strings.Repeat(" ", (door.Width-l)/2)
  99. } else {
  100. centering = ""
  101. }
  102. for _, o := range output {
  103. d.WriteA(centering, o, door.Reset, door.CRNL)
  104. }
  105. d.WriteA(door.CRNL)
  106. }
  107. press_a_key(d)
  108. var asylum door.ColorFont = FontAsylum()
  109. output, l = asylum.Output("Bugz ROCKS")
  110. if l > door.Width {
  111. output, l = asylum.Output("Aslym")
  112. }
  113. if l < door.Width {
  114. if center {
  115. centering = strings.Repeat(" ", (door.Width-l)/2)
  116. } else {
  117. centering = ""
  118. }
  119. for _, o := range output {
  120. d.WriteA(centering, o, door.Reset, door.CRNL)
  121. }
  122. d.WriteA(door.CRNL)
  123. }
  124. var brain door.ColorFont = FontBrainDmgBlu()
  125. output, l = brain.Output("I'm so BLUE")
  126. if l > door.Width {
  127. output, l = brain.Output("Blue")
  128. }
  129. if l < door.Width {
  130. if center {
  131. centering = strings.Repeat(" ", (door.Width-l)/2)
  132. } else {
  133. centering = ""
  134. }
  135. for _, o := range output {
  136. d.WriteA(centering, o, door.Reset, door.CRNL)
  137. }
  138. d.WriteA(door.CRNL)
  139. }
  140. var boner door.ColorFont = FontBoner()
  141. output, l = boner.Output("Welcome!")
  142. if l < door.Width {
  143. if center {
  144. centering = strings.Repeat(" ", (door.Width-l)/2)
  145. } else {
  146. centering = ""
  147. }
  148. for _, o := range output {
  149. d.WriteA(centering, o, door.Reset, door.CRNL)
  150. }
  151. d.WriteA(door.CRNL)
  152. }
  153. press_a_key(d)
  154. var descent door.ColorFont = FontDescent()
  155. output, l = descent.Output("Meanwhile...")
  156. if l > door.Width {
  157. output, l = descent.Output("BUGZ")
  158. }
  159. if l < door.Width {
  160. if center {
  161. centering = strings.Repeat(" ", (door.Width-l)/2)
  162. } else {
  163. centering = ""
  164. }
  165. for _, o := range output {
  166. d.WriteA(centering, o, door.Reset, door.CRNL)
  167. }
  168. d.WriteA(door.CRNL)
  169. }
  170. var remorse door.ColorFont = FontRemorse()
  171. output, l = remorse.Output("Enjoy the fonts")
  172. if l > door.Width {
  173. output, l = remorse.Output("Amazing")
  174. }
  175. if l < door.Width {
  176. if center {
  177. centering = strings.Repeat(" ", (door.Width-l)/2)
  178. } else {
  179. centering = ""
  180. }
  181. for _, o := range output {
  182. d.WriteA(centering, o, door.Reset, door.CRNL)
  183. }
  184. d.WriteA(door.CRNL)
  185. }
  186. var dungeon door.ColorFont = FontDungeon()
  187. output, l = dungeon.Output("Until NEXT time")
  188. if l > door.Width {
  189. output, l = dungeon.Output("Beware")
  190. }
  191. if l < door.Width {
  192. if center {
  193. centering = strings.Repeat(" ", (door.Width-l)/2)
  194. } else {
  195. centering = ""
  196. }
  197. for _, o := range output {
  198. d.WriteA(centering, o, door.Reset, door.CRNL)
  199. }
  200. d.WriteA(door.CRNL)
  201. }
  202. /*
  203. redgreen := FontArmageddon()
  204. white := redgreen.Scan(7)
  205. blue := redgreen.Scan(4)
  206. redgreen.Modify(1, white)
  207. redgreen.Modify(2, blue)
  208. */
  209. redgreen := FontRedGreen()
  210. output, l = redgreen.Output("Red-Green")
  211. center = false
  212. if l < door.Width {
  213. press_a_key(d)
  214. // Don't center this
  215. if center {
  216. centering = strings.Repeat(" ", (door.Width-l)/2)
  217. } else {
  218. centering = ""
  219. }
  220. for _, o := range output {
  221. d.WriteA(centering, o, door.Reset, door.CRNL)
  222. }
  223. d.WriteA(door.CRNL)
  224. // Center this part (below the MemStat panel)
  225. output, l = redgreen.Output("Software")
  226. center = true
  227. if center {
  228. centering = strings.Repeat(" ", (door.Width-l)/2)
  229. } else {
  230. centering = ""
  231. }
  232. for _, o := range output {
  233. d.WriteA(centering, o, door.Reset, door.CRNL)
  234. }
  235. d.WriteA(door.CRNL)
  236. }
  237. }