Commit de818286 authored by santiaago's avatar santiaago
Browse files

rename squares funcs.

parent be8af52a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -47,11 +47,11 @@ func Square(w http.ResponseWriter, r *http.Request) {

	if f := extract.Format(r); f == format.JPEG {
		m := image.NewRGBA(image.Rect(0, 0, size, size))
		squares.Squares(m, key, colors)
		squares.Image(m, key, colors)
		var img image.Image = m
		write.ImageJPEG(w, &img)
	} else if f == format.SVG {
		write.ImageSVG(w)
		squares.SquaresSVG(w, key, colors, size)
		squares.SVG(w, key, colors, size)
	}
}
+4 −4
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ func GridSVG(w http.ResponseWriter, color1, color2 color.RGBA, size int) {
	canvas.End()
}

// Squares builds an image with 6 by 6 quadrants of alternate colors.
func Squares(m *image.RGBA, key string, colors []color.RGBA) {
// Image builds an image.RGBA type with 6 by 6 quadrants of alternate colors.
func Image(m *image.RGBA, key string, colors []color.RGBA) {
	size := m.Bounds().Size()
	squares := 6
	quad := size.X / squares
@@ -85,8 +85,8 @@ func Squares(m *image.RGBA, key string, colors []color.RGBA) {
	}
}

// SquaresSVG builds an image with 6 by 6 quadrants of alternate colors.
func SquaresSVG(w http.ResponseWriter, key string, colors []color.RGBA, size int) {
// SVG builds an svg image with 6 by 6 quadrants of alternate colors.
func SVG(w http.ResponseWriter, key string, colors []color.RGBA, size int) {
	canvas := svg.New(w)
	canvas.Start(size, size)

+2 −2
Original line number Diff line number Diff line
@@ -38,13 +38,13 @@ func TestGridSVG(t *testing.T) {
func TestSquares(t *testing.T) {
	t.Parallel()
	img := image.NewRGBA(image.Rect(0, 0, 10, 10))
	Squares(img, key, colorTheme)
	Image(img, key, colorTheme)
}

func TestSquaresSVG(t *testing.T) {
	t.Parallel()
	rec := httptest.NewRecorder()
	SquaresSVG(rec, key, colorTheme, 10)
	SVG(rec, key, colorTheme, 10)
	if rec.Code != http.StatusOK {
		t.Errorf("returned %v. Expected %v.", rec.Code, http.StatusOK)
	}