Skip to content

Commit

Permalink
made sesame optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Doarakko committed Apr 2, 2022
1 parent d2e6544 commit 512efe4
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"image/png"
"io/ioutil"
"log"
"math/rand"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -55,6 +54,7 @@ func saveImage(filename string, img image.Image) error {

var toppings [6]Topping
var top Topping
var topWithSesame Topping
var bottom Topping

func init() {
Expand All @@ -63,12 +63,12 @@ func init() {
log.Fatal(err)
}

if randBool() {
top.Img, err = loadImage(fs, "/top.png")
} else {
top.Img, err = loadImage(fs, "/top-sesame.png")
top.Img, err = loadImage(fs, "/top.png")
if err != nil {
log.Fatal(err)
}

topWithSesame.Img, err = loadImage(fs, "/top-sesame.png")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -114,16 +114,22 @@ func main() {
var nBurger int
var rInterval float64
var fileName string
var sesame bool

flag.IntVar(&nBurger, "n", 1, "number of big burger")
flag.Float64Var(&rInterval, "i", 1.0, "rate of intervals")
flag.StringVar(&fileName, "o", "", "output image file")
flag.BoolVar(&sesame, "s", false,"buns with sesame")

for i := 0; i < len(toppings); i++ {
flag.IntVar(&toppings[i].Count, toppings[i].Option, toppings[i].Count, fmt.Sprintf("how many %s", toppings[i].Name))
}
flag.Parse()

if sesame{
top = topWithSesame
}

// Count number of unique toppings
uniqueToppingCount := 0
for i := 0; i < len(toppings); i++ {
Expand Down Expand Up @@ -227,8 +233,3 @@ func getDA2() string {
}
return string(b[:n])
}

func randBool() bool {
rand.Seed(time.Now().UnixNano())
return rand.Intn(2) == 1
}

0 comments on commit 512efe4

Please sign in to comment.