Commit f015b017 authored by santiaago's avatar santiaago
Browse files

removing support to hexalines different than 6.

parent 725af563
Loading
Loading
Loading
Loading
+24 −60
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ func Hexa(w http.ResponseWriter, key string, colors []color.RGBA, size, lines in
}

func isFill1InHexagon(xL, yL, lines int) bool {
	if lines%6 == 0 {

	half := lines / 2
	start := half / 2
	if xL < start+1 {
@@ -92,29 +92,10 @@ func isFill1InHexagon(xL, yL, lines int) bool {
		}
	}
	return false
	} else if lines%4 == 0 {
		if xL == 0 {
			if yL > 1 && yL < 6 {
				return true
			}
		}
		if xL == 1 || xL == 2 {
			if yL > 0 && yL < 7 {
				return true
			}
		}
		if xL == 3 {
			if yL >= 0 && yL <= 7 {
				return true
			}
		}
		return false
	}
	return false
}

func isFill2InHexagon(xL, yL, lines int) bool {
	if lines%6 == 0 {

	half := lines / 2
	start := half / 2

@@ -133,23 +114,6 @@ func isFill2InHexagon(xL, yL, lines int) bool {
			return true
		}
	}
	} else if lines%4 == 0 {
		if xL == 0 || xL == 1 {
			if yL > 0 && yL < 6 {
				return true
			}
		}
		if xL == 1 {
			if yL > 0 && yL < 6 {
				return true
			}
		}
		if xL == 2 || xL == 3 {
			if yL >= 0 && yL <= 6 {
				return true
			}
		}
	}
	return false
}

+3 −2
Original line number Diff line number Diff line
@@ -51,12 +51,13 @@ func Theme(r *http.Request) string {
}

// Hexalines return the value of the hexalines parameter in the http.Request.
// possible values: 6 or 8. Default value : 6
// possible values: 6 or 4. Default value : 6
// remark: we only support hexalines of 6 right now.
func Hexalines(r *http.Request) int {
	s := strings.ToLower(r.FormValue("hexalines"))
	if len(s) > 0 {
		if n, err := strconv.ParseInt(s, 0, 64); err == nil {
			if n%6 == 0 || n%4 == 0 {
			if n == 6 {
				return int(n)
			}
		}
+2 −1
Original line number Diff line number Diff line
@@ -90,7 +90,8 @@ func TestHexalines(t *testing.T) {
	}{
		{"test wrong input", "http://www.tg.c?hexalines=h", 6},
		{"test no input", "http://www.tg.c", 6},
		{"test good input", "http://www.tg.c?hexalines=4", 4},
		// we only support hexalines = 6 right now
		{"test good input", "http://www.tg.c?hexalines=4", 6},
	}

	for _, test := range tests {