Esempio n. 1
0
// 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)
}
Esempio n. 2
0
// BannerRandomGradient handler for "/squares/banner/random/gradient"
// generates a random banner grid image with gradient colors from brighter to darker color.
func BannerRandomGradient(w http.ResponseWriter, r *http.Request) {
	width := extract.Width(r)
	height := extract.Height(r)
	xsquares := extract.XSquares(r)
	colors := extract.Colors(r)

	if f := extract.Format(r); f == format.JPEG {
		m := image.NewRGBA(image.Rect(0, 0, width, height))
		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, xsquares)
	}
}
Esempio n. 3
0
// 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)
	}
}