Loading controllers/squares/banner.go +6 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import ( func BannerRandom(w http.ResponseWriter, r *http.Request) { width := extract.Width(r) height := extract.Height(r) xsquares := extract.XSquares(r) numColors := extract.NumColors(r) Loading @@ -38,12 +39,12 @@ func BannerRandom(w http.ResponseWriter, r *http.Request) { if f := extract.Format(r); f == format.JPEG { m := image.NewRGBA(image.Rect(0, 0, width, height)) squares.RandomGrid(m, colors, 50) squares.RandomGrid(m, colors, xsquares) var img image.Image = m write.ImageJPEG(w, &img) } else if f == format.SVG { write.ImageSVG(w) squares.RandomGridSVG(w, colors, width, height, 50) squares.RandomGridSVG(w, colors, width, height, xsquares) } } Loading @@ -52,6 +53,7 @@ func BannerRandom(w http.ResponseWriter, r *http.Request) { func BannerRandomGradient(w http.ResponseWriter, r *http.Request) { width := extract.Width(r) height := extract.Height(r) xsquares := extract.XSquares(r) numColors := extract.NumColors(r) Loading @@ -73,11 +75,11 @@ func BannerRandomGradient(w http.ResponseWriter, r *http.Request) { if f := extract.Format(r); f == format.JPEG { m := image.NewRGBA(image.Rect(0, 0, width, height)) squares.RandomGradientGrid(m, colors, 50) squares.RandomGradientGrid(m, colors, xsquares) var img image.Image = m write.ImageJPEG(w, &img) } else if f == format.SVG { write.ImageSVG(w) squares.RandomGradientGridSVG(w, colors, width, height, 50) squares.RandomGradientGridSVG(w, colors, width, height, xsquares) } } extract/extract.go +14 −0 Original line number Diff line number Diff line Loading @@ -171,5 +171,19 @@ func Height(r *http.Request) int { } } return 300 } // XSquares returns the value of the 'xs' parameter in the http.Request. // Used to defined the number of squares that are wanted in the x axis of an image func XSquares(r *http.Request) int { strXS := r.FormValue("xs") if len(strXS) > 0 { if xs, errXS := strconv.ParseInt(strXS, 0, 64); errXS == nil { ixs := int(xs) if ixs > 0 { return ixs } } } return 50 } Loading
controllers/squares/banner.go +6 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import ( func BannerRandom(w http.ResponseWriter, r *http.Request) { width := extract.Width(r) height := extract.Height(r) xsquares := extract.XSquares(r) numColors := extract.NumColors(r) Loading @@ -38,12 +39,12 @@ func BannerRandom(w http.ResponseWriter, r *http.Request) { if f := extract.Format(r); f == format.JPEG { m := image.NewRGBA(image.Rect(0, 0, width, height)) squares.RandomGrid(m, colors, 50) squares.RandomGrid(m, colors, xsquares) var img image.Image = m write.ImageJPEG(w, &img) } else if f == format.SVG { write.ImageSVG(w) squares.RandomGridSVG(w, colors, width, height, 50) squares.RandomGridSVG(w, colors, width, height, xsquares) } } Loading @@ -52,6 +53,7 @@ func BannerRandom(w http.ResponseWriter, r *http.Request) { func BannerRandomGradient(w http.ResponseWriter, r *http.Request) { width := extract.Width(r) height := extract.Height(r) xsquares := extract.XSquares(r) numColors := extract.NumColors(r) Loading @@ -73,11 +75,11 @@ func BannerRandomGradient(w http.ResponseWriter, r *http.Request) { if f := extract.Format(r); f == format.JPEG { m := image.NewRGBA(image.Rect(0, 0, width, height)) squares.RandomGradientGrid(m, colors, 50) squares.RandomGradientGrid(m, colors, xsquares) var img image.Image = m write.ImageJPEG(w, &img) } else if f == format.SVG { write.ImageSVG(w) squares.RandomGradientGridSVG(w, colors, width, height, 50) squares.RandomGradientGridSVG(w, colors, width, height, xsquares) } }
extract/extract.go +14 −0 Original line number Diff line number Diff line Loading @@ -171,5 +171,19 @@ func Height(r *http.Request) int { } } return 300 } // XSquares returns the value of the 'xs' parameter in the http.Request. // Used to defined the number of squares that are wanted in the x axis of an image func XSquares(r *http.Request) int { strXS := r.FormValue("xs") if len(strXS) > 0 { if xs, errXS := strconv.ParseInt(strXS, 0, 64); errXS == nil { ixs := int(xs) if ixs > 0 { return ixs } } } return 50 }