Loading controllers/squares/square.go +2 −2 Original line number Diff line number Diff line Loading @@ -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) } } draw/squares/squares.go +4 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) Loading draw/squares/squares_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -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) } Loading Loading
controllers/squares/square.go +2 −2 Original line number Diff line number Diff line Loading @@ -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) } }
draw/squares/squares.go +4 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) Loading
draw/squares/squares_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -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) } Loading