Commit f4063dff authored by santiaago's avatar santiaago
Browse files

orginize draw packages

draw now has two packages: draw/isogrids and draw/squares as well as draw pkg for common things.
parent 9db67bc1
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import (
	"net/http"

	"github.com/taironas/tinygraphs/colors"
	"github.com/taironas/tinygraphs/draw"
	"github.com/taironas/tinygraphs/draw/squares"
	"github.com/taironas/tinygraphs/extract"
	"github.com/taironas/tinygraphs/format"
	"github.com/taironas/tinygraphs/write"
@@ -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))
		draw.Grid6X6(m, c1, c2)
		squares.Grid6X6(m, c1, c2)
		var img image.Image = m
		write.ImageJPEG(w, &img)
	} else if f == format.SVG {
		write.ImageSVG(w)
		draw.Grid6X6SVG(w, c1, c2, size)
		squares.Grid6X6SVG(w, c1, c2, size)
	}
}
+5 −5
Original line number Diff line number Diff line
@@ -5,13 +5,13 @@ import (
	"net/http"

	"github.com/taironas/tinygraphs/colors"
	"github.com/taironas/tinygraphs/draw"
	"github.com/taironas/tinygraphs/draw/isogrids"
	"github.com/taironas/tinygraphs/extract"
	"github.com/taironas/tinygraphs/write"
)

// Diagonals is the handler for /isogrids/labs/diagonals
// builds a 10x10 full diagonal grid.
// builds a full diagonal grid.
func Diagonals(w http.ResponseWriter, r *http.Request) {

	colorMap := colors.MapOfColorThemes()
@@ -25,11 +25,11 @@ func Diagonals(w http.ResponseWriter, r *http.Request) {
	}
	size := extract.Size(r)
	write.ImageSVG(w)
	draw.Diagonals(w, "", bg, fg, size)
	isogrids.Diagonals(w, "", bg, fg, size)
}

// Diagonals is the handler for /isogrids/labs/diagonals
// builds a 10x10 half diagonal (each diagonal goes to the middle of the square) grid.
// builds a half diagonal (each diagonal goes to the middle of the square) grid.
func HalfDiagonals(w http.ResponseWriter, r *http.Request) {

	colorMap := colors.MapOfColorThemes()
@@ -43,5 +43,5 @@ func HalfDiagonals(w http.ResponseWriter, r *http.Request) {
	}
	size := extract.Size(r)
	write.ImageSVG(w)
	draw.HalfDiagonals(w, "", bg, fg, size)
	isogrids.HalfDiagonals(w, "", bg, fg, size)
}
+3 −3
Original line number Diff line number Diff line
@@ -9,13 +9,13 @@ import (

	"github.com/taironas/route"
	"github.com/taironas/tinygraphs/colors"
	"github.com/taironas/tinygraphs/draw"
	"github.com/taironas/tinygraphs/draw/isogrids"
	"github.com/taironas/tinygraphs/extract"
	"github.com/taironas/tinygraphs/write"
)

// Hexa is the handler for /isogrids/hexa/:key
// builds an hexagon from a 10x10 grid with alternate colors.
// builds an hexagon with alternate colors.
func Hexa(w http.ResponseWriter, r *http.Request) {
	var err error
	colorMap := colors.MapOfColorThemes()
@@ -56,5 +56,5 @@ func Hexa(w http.ResponseWriter, r *http.Request) {
		colors = append(colors, bg, fg)
	}
	write.ImageSVG(w)
	draw.IsogridsHexa(w, key, colors, size, lines)
	isogrids.IsogridsHexa(w, key, colors, size, lines)
}
+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import (

	"github.com/taironas/route"
	"github.com/taironas/tinygraphs/colors"
	"github.com/taironas/tinygraphs/draw"
	"github.com/taironas/tinygraphs/draw/isogrids"
	"github.com/taironas/tinygraphs/extract"
	"github.com/taironas/tinygraphs/write"
)
@@ -59,5 +59,5 @@ func Isogrids(w http.ResponseWriter, r *http.Request) {
	}

	write.ImageSVG(w)
	draw.Isogrids(w, key, colors, size)
	isogrids.Isogrids(w, key, colors, size)
}
+3 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ import (
	"net/http"

	"github.com/taironas/tinygraphs/colors"
	"github.com/taironas/tinygraphs/draw"
	"github.com/taironas/tinygraphs/draw/isogrids"
	"github.com/taironas/tinygraphs/extract"
	"github.com/taironas/tinygraphs/write"
)
@@ -25,7 +25,7 @@ func GridBW(w http.ResponseWriter, r *http.Request) {
	}
	size := extract.Size(r)
	write.ImageSVG(w)
	draw.IsogridsBW(w, "", bg, fg, size)
	isogrids.IsogridsBW(w, "", bg, fg, size)
}

// Grid2Colors is the handler for /isogrids/labs/grid2colors
@@ -34,5 +34,5 @@ func Grid2Colors(w http.ResponseWriter, r *http.Request) {

	size := extract.Size(r)
	write.ImageSVG(w)
	draw.Isogrids2Colors(w, "", size)
	isogrids.Isogrids2Colors(w, "", size)
}
Loading