Commit f8ed3385 authored by santiaago's avatar santiaago
Browse files

support svg in squares/random/color route

parent 84d89154
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -44,10 +44,16 @@ func RandomColor(w http.ResponseWriter, r *http.Request) {
		log.Printf("error when extracting permalink id: %v", err)
	} else {
		size := size(r)
		m := image.NewRGBA(image.Rect(0, 0, size, size))
		colorMap := colors.MapOfColorPatterns()
		if format := format(r); format == JPEG {
			m := image.NewRGBA(image.Rect(0, 0, size, size))
			draw.RandomGrid6X6(m, colorMap[int(intID)][0], colorMap[int(intID)][1])
			var img image.Image = m
			write.ImageJPEG(w, &img)
		} else if format == SVG {
			canvas := svg.New(w)
			draw.RandomGrid6X6SVG(canvas, colorMap[int(intID)][0], colorMap[int(intID)][1], size)
			write.ImageSVG(w, canvas)
		}
	}
}