Skip to content

Instantly share code, notes, and snippets.

@ajstarks
Created February 13, 2018 12:19
Show Gist options
  • Save ajstarks/1548967b84a0506c183a7cacffba4f24 to your computer and use it in GitHub Desktop.
Save ajstarks/1548967b84a0506c183a7cacffba4f24 to your computer and use it in GitHub Desktop.
package main
import (
"os"
"strings"
"github.com/ajstarks/deck/generate"
)
var xmlmap = strings.NewReplacer(
"&", "&",
"<", "&lt;",
">", "&gt;")
func xmlesc(s string) string {
return xmlmap.Replace(s)
}
func matrix(deck *generate.Deck, s string, x, y, size, spacing float64, nr, nc int) {
yp := y
k := 0
color := ""
for i:=0; i < nr; i++ {
xp := x
for j:=0; j < nc; j++ {
if k >= len(s) {
break
}
switch s[k] {
case 'w' : color = "rgb(255,249,225)"
case 'h' : color = "rgb(188,151,97)"
case 'b' : color = "rgb(123,76,46)"
case 'o' : color = "gray"
}
//deck.TextMid(xp, yp, "A", "sans", size, color)
deck.Circle(xp, yp, size/2, color)
//deck.TextMid(xp, yp-(spacing*.24), xmlesc(string(s[k])), "mono", size/4, "red")
k++
xp += spacing
}
yp -= spacing
}
}
func main() {
//data := "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkkkkkkkkkkkkkkkkkk"
prison := "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwhhhhhhhhhhhhhhhhhhhbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbboo"
prisonpop := "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwhhhhhhhhhhhhhhhhbbbbbbbbbbbbbooooooo"
deck := generate.NewSlides(os.Stdout, 0, 0)
deck.StartDeck()
deck.StartSlide("rgb(164,178,226)", "white")
matrix(deck, prisonpop, 30, 80, 3, 5, 10, 10)
deck.EndSlide()
deck.StartSlide("rgb(164,178,226)", "white")
matrix(deck, prison, 30, 80, 3, 5, 10, 10)
deck.EndSlide()
deck.EndDeck()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment