Commit df52db56 authored by santiaago's avatar santiaago
Browse files

rename square functions

parent adf2d7cc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,11 +34,11 @@ func Checkerboard(w http.ResponseWriter, r *http.Request) {
	}
	if f := extract.Format(r); f == format.JPEG {
		m := image.NewRGBA(image.Rect(0, 0, size, size))
		squares.Grid6X6(m, c1, c2)
		squares.Grid(m, c1, c2)
		var img image.Image = m
		write.ImageJPEG(w, &img)
	} else if f == format.SVG {
		write.ImageSVG(w)
		squares.Grid6X6SVG(w, c1, c2, size)
		squares.GridSVG(w, c1, c2, size)
	}
}
+2 −2
Original line number Diff line number Diff line
@@ -36,11 +36,11 @@ func Random(w http.ResponseWriter, r *http.Request) {

	if f := extract.Format(r); f == format.JPEG {
		m := image.NewRGBA(image.Rect(0, 0, size, size))
		squares.RandomGrid6X6(m, colors)
		squares.RandomGrid(m, colors)
		var img image.Image = m
		write.ImageJPEG(w, &img)
	} else if f == format.SVG {
		write.ImageSVG(w)
		squares.RandomGrid6X6SVG(w, colors, size)
		squares.RandomGridSVG(w, colors, size)
	}
}
+7 −7
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ import (
	"github.com/taironas/tinygraphs/draw"
)

//Grid6X6 builds an image with 6X6 quadrants of alternate colors.
func Grid6X6(m *image.RGBA, color1, color2 color.RGBA) {
//Grid builds an image with 6X6 quadrants of alternate colors.
func Grid(m *image.RGBA, color1, color2 color.RGBA) {
	size := m.Bounds().Size()
	quad := size.X / 6
	for x := 0; x < size.X; x++ {
@@ -28,8 +28,8 @@ func Grid6X6(m *image.RGBA, color1, color2 color.RGBA) {
	}
}

// Grid6X6SVG builds an image with 6X6 quadrants of alternate colors.
func Grid6X6SVG(w http.ResponseWriter, color1, color2 color.RGBA, size int) {
// GridSVG builds an image with 6 by 6 quadrants of alternate colors.
func GridSVG(w http.ResponseWriter, color1, color2 color.RGBA, size int) {
	canvas := svg.New(w)
	canvas.Start(size, size)
	squares := 6
@@ -54,8 +54,8 @@ func Grid6X6SVG(w http.ResponseWriter, color1, color2 color.RGBA, size int) {
	canvas.End()
}

// RandomGrid6X6 builds a grid image with with 2 colors selected at random for each quadrant.
func RandomGrid6X6(m *image.RGBA, colors []color.RGBA) {
// RandomGrid builds a 6 by 6 grid image with with 2 colors selected at random for each quadrant.
func RandomGrid(m *image.RGBA, colors []color.RGBA) {
	size := m.Bounds().Size()
	quad := size.X / 6
	colorMap := make(map[int]color.RGBA)
@@ -77,7 +77,7 @@ func RandomGrid6X6(m *image.RGBA, colors []color.RGBA) {
}

// RandomGrid6X6SVG builds a grid image with with 2 colors selected at random for each quadrant.
func RandomGrid6X6SVG(w http.ResponseWriter, colors []color.RGBA, size int) {
func RandomGridSVG(w http.ResponseWriter, colors []color.RGBA, size int) {
	canvas := svg.New(w)
	canvas.Start(size, size)
	squares := 6