Commit 948dec12 authored by santiaago's avatar santiaago
Browse files

clean up

parent bc97dd5b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ func main() {
	r.HandleFunc("/labs/isogrids/diagonals", isogrids.Diagonals)
	r.HandleFunc("/labs/isogrids/halfdiagonals", isogrids.HalfDiagonals)
	r.HandleFunc("/labs/isogrids/gridbw", isogrids.GridBW)
	r.HandleFunc("/labs/isogrids/labs/grid2colors", isogrids.Grid2Colors)
	r.HandleFunc("/labs/isogrids/random", isogrids.Random)
	r.HandleFunc("/labs/isogrids/random-mirror", isogrids.RandomMirror)

+0 −9
Original line number Diff line number Diff line
@@ -18,12 +18,3 @@ func GridBW(w http.ResponseWriter, r *http.Request) {
	write.ImageSVG(w)
	isogrids.BlackWhite(w, "", bg, fg, size)
}

// Grid2Colors is the handler for /isogrids/labs/grid2colors
// builds a 10x10 grid that alternate black and white colors.
func Grid2Colors(w http.ResponseWriter, r *http.Request) {

	size := extract.Size(r)
	write.ImageSVG(w)
	isogrids.TwoColors(w, "", size)
}
+0 −56
Original line number Diff line number Diff line
@@ -161,59 +161,3 @@ func BlackWhite(w http.ResponseWriter, key string, color1, color2 color.RGBA, si

	canvas.End()
}

// TwoColors builds an image with 10x10 grids of half diagonals
func TwoColors(w http.ResponseWriter, key string, size int) {
	canvas := svg.New(w)
	canvas.Start(size, size)

	lines := 10
	fringeSize := size / lines

	for xL := -1; xL <= lines; xL++ {
		for yL := -1; yL <= lines; yL++ {
			var x1, x2, x3, y1, y2, y3 int
			if (xL % 2) == 0 {
				x1 = (xL) * fringeSize
				x2 = (xL + 1) * fringeSize
				x3 = x1
				y1 = yL * fringeSize
				y2 = y1 + fringeSize/2
				y3 = (yL + 1) * fringeSize
			} else {
				x1 = (xL + 1) * fringeSize
				x2 = xL * fringeSize
				x3 = x1
				y1 = yL * fringeSize
				y2 = y1 + fringeSize/2
				y3 = (yL + 1) * fringeSize
			}
			xs := []int{x1, x2, x3}
			ys := []int{y1, y2, y3}
			canvas.Polygon(xs, ys, fmt.Sprintf("stroke:black;stroke-width:2;  fill: rgb(61, 171, 76);"))

			var x11, x12, x13, y11, y12, y13 int
			if (xL % 2) == 0 {
				x11 = (xL + 1) * fringeSize
				x12 = (xL) * fringeSize
				x13 = x11
				y11 = yL*fringeSize + fringeSize/2
				y12 = y11 + fringeSize/2
				y13 = (yL+1)*fringeSize + fringeSize/2
			} else {
				x11 = (xL) * fringeSize
				x12 = (xL + 1) * fringeSize
				x13 = x11
				y11 = yL*fringeSize + fringeSize/2
				y12 = y1 + fringeSize
				y13 = (yL+1)*fringeSize + fringeSize/2
			}
			xs1 := []int{x11, x12, x13}
			ys1 := []int{y11, y12, y13}
			canvas.Polygon(xs1, ys1, fmt.Sprintf("stroke:black;stroke-width:2; fill: rgb(31, 71, 176);"))

		}
	}

	canvas.End()
}