// RandomMirror handler for "/labs/isogrids/random-mirror" // generates a random grid image symetric in the middle of the image. func RandomMirror(w http.ResponseWriter, r *http.Request) { size := extract.Size(r) colors := extract.Colors(r) prob := extract.Probability(r, 1/float64(len(colors))) write.ImageSVG(w) isogrids.RandomMirror(w, colors, size, prob) }
// Random handler for /isogrids/random. // Generates a random isogrid image. func Random(w http.ResponseWriter, r *http.Request) { colors := extract.Colors(r) prob := extract.Probability(r, 1/float64(len(colors))) size := extract.Size(r) lines := extract.Lines(r) write.ImageSVG(w) isogrids.Random(w, colors, size, size, lines, prob) }
// BannerRandom handler for /isogrids/banner/random. // Generates a random banner isogrid image. func BannerRandom(w http.ResponseWriter, r *http.Request) { width := extract.Width(r) height := extract.Height(r) colors := extract.Colors(r) prob := extract.Probability(r, 1/float64(len(colors))) xt := extract.XTriangles(r) write.ImageSVG(w) isogrids.Random(w, colors, width, height, xt, prob) }
// BannerGradient handler for "labs/squares/banner/gradient" // generates a color gradient random grid image. func BannerGradient(w http.ResponseWriter, r *http.Request) { width := extract.Width(r) height := extract.Height(r) xsquares := extract.XSquares(r) gv := extract.GradientVector(r, uint8(0), uint8(0), uint8(width), uint8(0)) gColors := extract.GColors(r) colors := extract.Colors(r) prob := extract.Probability(r, 1/float64(len(gColors))) write.ImageSVG(w) squares.RandomGradientColorSVG(w, colors, gColors, gv, width, height, xsquares, prob) }
// Random handler for "/squares/random" // generates a random 6 by 6 grid image. func Random(w http.ResponseWriter, r *http.Request) { size := extract.Size(r) colors := extract.Colors(r) prob := extract.Probability(r, 1/float64(len(colors))) if f := extract.Format(r); f == format.JPEG { m := image.NewRGBA(image.Rect(0, 0, size, size)) squares.RandomGrid(m, colors, 6, prob) var img image.Image = m write.ImageJPEG(w, &img) } else if f == format.SVG { write.ImageSVG(w) squares.RandomGridSVG(w, colors, size, size, 6, prob) } }
// BannerRandom handler for "/squares/banner/random" // generates a random banner grid image. func BannerRandom(w http.ResponseWriter, r *http.Request) { width := extract.Width(r) height := extract.Height(r) xsquares := extract.XSquares(r) colors := extract.Colors(r) prob := extract.Probability(r, 1/float64(len(colors))) if f := extract.Format(r); f == format.JPEG { m := image.NewRGBA(image.Rect(0, 0, width, height)) squares.RandomGrid(m, colors, xsquares, prob) var img image.Image = m write.ImageJPEG(w, &img) } else if f == format.SVG { write.ImageSVG(w) squares.RandomGridSVG(w, colors, width, height, xsquares, prob) } }