Loading controllers/isogrids/diagonals.go +4 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ import ( "github.com/taironas/tinygraphs/write" ) // Diagonals is the handler for /isogrids/labs/diagonals // builds a 10x10 full diagonal grid. func Diagonals(w http.ResponseWriter, r *http.Request) { colorMap := colors.MapOfColorThemes() Loading @@ -26,6 +28,8 @@ func Diagonals(w http.ResponseWriter, r *http.Request) { draw.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. func HalfDiagonals(w http.ResponseWriter, r *http.Request) { colorMap := colors.MapOfColorThemes() Loading controllers/isogrids/labs.go +5 −10 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ import ( "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) { colorMap := colors.MapOfColorThemes() Loading @@ -26,18 +28,11 @@ func GridBW(w http.ResponseWriter, r *http.Request) { draw.IsogridsBW(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) { colorMap := colors.MapOfColorThemes() var err error var bg, fg color.RGBA if bg, err = extract.Background(r); err != nil { bg = colorMap["base"][0] } if fg, err = extract.Foreground(r); err != nil { fg = colorMap["base"][1] } size := extract.Size(r) write.ImageSVG(w) draw.Isogrids2Colors(w, "", bg, fg, size) draw.Isogrids2Colors(w, "", size) } draw/isogridsLabs.go +2 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,7 @@ func IsogridsBW(w http.ResponseWriter, key string, color1, color2 color.RGBA, si } // Isogrids builds an image with 10x10 grids of half diagonals func Isogrids2Colors(w http.ResponseWriter, key string, color1, color2 color.RGBA, size int) { func Isogrids2Colors(w http.ResponseWriter, key string, size int) { canvas := svg.New(w) canvas.Start(size, size) Loading @@ -189,7 +189,7 @@ func Isogrids2Colors(w http.ResponseWriter, key string, color1, color2 color.RGB } xs := []int{x1, x2, x3} ys := []int{y1, y2, y3} canvas.Polygon(xs, ys, fmt.Sprintf("stroke:black;stroke-width:2; %s", fillFromRGBA(color2))) 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 { Loading Loading
controllers/isogrids/diagonals.go +4 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ import ( "github.com/taironas/tinygraphs/write" ) // Diagonals is the handler for /isogrids/labs/diagonals // builds a 10x10 full diagonal grid. func Diagonals(w http.ResponseWriter, r *http.Request) { colorMap := colors.MapOfColorThemes() Loading @@ -26,6 +28,8 @@ func Diagonals(w http.ResponseWriter, r *http.Request) { draw.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. func HalfDiagonals(w http.ResponseWriter, r *http.Request) { colorMap := colors.MapOfColorThemes() Loading
controllers/isogrids/labs.go +5 −10 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ import ( "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) { colorMap := colors.MapOfColorThemes() Loading @@ -26,18 +28,11 @@ func GridBW(w http.ResponseWriter, r *http.Request) { draw.IsogridsBW(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) { colorMap := colors.MapOfColorThemes() var err error var bg, fg color.RGBA if bg, err = extract.Background(r); err != nil { bg = colorMap["base"][0] } if fg, err = extract.Foreground(r); err != nil { fg = colorMap["base"][1] } size := extract.Size(r) write.ImageSVG(w) draw.Isogrids2Colors(w, "", bg, fg, size) draw.Isogrids2Colors(w, "", size) }
draw/isogridsLabs.go +2 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,7 @@ func IsogridsBW(w http.ResponseWriter, key string, color1, color2 color.RGBA, si } // Isogrids builds an image with 10x10 grids of half diagonals func Isogrids2Colors(w http.ResponseWriter, key string, color1, color2 color.RGBA, size int) { func Isogrids2Colors(w http.ResponseWriter, key string, size int) { canvas := svg.New(w) canvas.Start(size, size) Loading @@ -189,7 +189,7 @@ func Isogrids2Colors(w http.ResponseWriter, key string, color1, color2 color.RGB } xs := []int{x1, x2, x3} ys := []int{y1, y2, y3} canvas.Polygon(xs, ys, fmt.Sprintf("stroke:black;stroke-width:2; %s", fillFromRGBA(color2))) 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 { Loading