Loading app-backend/main.go +0 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ func main() { r.HandleFunc("/labs/isogrids/skeleton", isogrids.Skeleton) 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/random", isogrids.Random) r.HandleFunc("/labs/isogrids/random-mirror", isogrids.RandomMirror) Loading controllers/isogrids/labs.godeleted 100644 → 0 +0 −20 Original line number Diff line number Diff line package isogrids import ( "net/http" "github.com/taironas/tinygraphs/colors" "github.com/taironas/tinygraphs/draw/isogrids" "github.com/taironas/tinygraphs/extract" "github.com/taironas/tinygraphs/write" ) // GridBW is the handler for /isogrids/labs/gridbw // builds a 10x10 grid that alternate black and white colors. func GridBW(w http.ResponseWriter, r *http.Request) { bg, fg := extract.ExtraColors(r, colors.MapOfColorThemes()) size := extract.Size(r) write.ImageSVG(w) isogrids.BlackWhite(w, "", bg, fg, size) } controllers/isogrids/labs_test.go +0 −2 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ func TestLabs(t *testing.T) { labs := [...]Labs{ {"/isogrids/labs/skeleton", Skeleton}, {"/isogrids/labs/gridbw", GridBW}, {"/isogrids/labs/gird2colors", Grid2Colors}, } for _, lab := range labs { r.HandleFunc(lab.url, lab.handler) Loading draw/isogrids/labs.go +0 −35 Original line number Diff line number Diff line Loading @@ -126,38 +126,3 @@ func Skeleton(w http.ResponseWriter, key string, color1, color2 color.RGBA, size canvas.End() } // BlackWhite builds an image with 10x10 grids of half diagonals. func BlackWhite(w http.ResponseWriter, key string, color1, color2 color.RGBA, size int) { canvas := svg.New(w) canvas.Start(size, size) lines := 10 fringeSize := size / lines for xL := 0; xL <= lines; xL++ { for yL := 0; 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; %s", draw.FillFromRGBA(color2))) } } canvas.End() } Loading
app-backend/main.go +0 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ func main() { r.HandleFunc("/labs/isogrids/skeleton", isogrids.Skeleton) 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/random", isogrids.Random) r.HandleFunc("/labs/isogrids/random-mirror", isogrids.RandomMirror) Loading
controllers/isogrids/labs.godeleted 100644 → 0 +0 −20 Original line number Diff line number Diff line package isogrids import ( "net/http" "github.com/taironas/tinygraphs/colors" "github.com/taironas/tinygraphs/draw/isogrids" "github.com/taironas/tinygraphs/extract" "github.com/taironas/tinygraphs/write" ) // GridBW is the handler for /isogrids/labs/gridbw // builds a 10x10 grid that alternate black and white colors. func GridBW(w http.ResponseWriter, r *http.Request) { bg, fg := extract.ExtraColors(r, colors.MapOfColorThemes()) size := extract.Size(r) write.ImageSVG(w) isogrids.BlackWhite(w, "", bg, fg, size) }
controllers/isogrids/labs_test.go +0 −2 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ func TestLabs(t *testing.T) { labs := [...]Labs{ {"/isogrids/labs/skeleton", Skeleton}, {"/isogrids/labs/gridbw", GridBW}, {"/isogrids/labs/gird2colors", Grid2Colors}, } for _, lab := range labs { r.HandleFunc(lab.url, lab.handler) Loading
draw/isogrids/labs.go +0 −35 Original line number Diff line number Diff line Loading @@ -126,38 +126,3 @@ func Skeleton(w http.ResponseWriter, key string, color1, color2 color.RGBA, size canvas.End() } // BlackWhite builds an image with 10x10 grids of half diagonals. func BlackWhite(w http.ResponseWriter, key string, color1, color2 color.RGBA, size int) { canvas := svg.New(w) canvas.Start(size, size) lines := 10 fringeSize := size / lines for xL := 0; xL <= lines; xL++ { for yL := 0; 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; %s", draw.FillFromRGBA(color2))) } } canvas.End() }