Loading draw/isogrids/labs.go +22 −22 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ import ( "github.com/taironas/tinygraphs/draw" ) // Diagonals builds an image with 10x10 grids of half diagonals // Diagonals builds an image with 10x10 grids of diagonals. func Diagonals(w http.ResponseWriter, key string, color1, color2 color.RGBA, size int) { canvas := svg.New(w) canvas.Start(size, size) Loading @@ -17,33 +17,33 @@ func Diagonals(w http.ResponseWriter, key string, color1, color2 color.RGBA, siz lines := 10 fringeSize := size / lines style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Gstyle(style) for xL := 0; xL <= lines; xL++ { x := xL * fringeSize lastY := (lines) * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Line(x, 0, x, lastY, style) canvas.Line(x, 0, x, lastY) } for xL := 0; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := 0 yPrev := (xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x, 0, style) canvas.Line(xPrev, yPrev, x, 0) } } for xL := -2 * lines; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := lines * fringeSize yPrev := (lines - xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x, 0, style) canvas.Line(xPrev, yPrev, x, 0) } } canvas.Gend() canvas.End() } Loading @@ -55,33 +55,33 @@ func HalfDiagonals(w http.ResponseWriter, key string, color1, color2 color.RGBA, lines := 10 fringeSize := size / lines style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Gstyle(style) for xL := 0; xL <= lines; xL++ { x := xL * fringeSize lastY := (lines) * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Line(x, 0, x, lastY, style) canvas.Line(x, 0, x, lastY) } for xL := 0; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := 0 yPrev := (xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x*2, 0, style) canvas.Line(xPrev, yPrev, x*2, 0) } } for xL := -2 * lines; xL <= 2*lines; xL++ { x := xL * fringeSize * 2 style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := lines * fringeSize yPrev := (lines - xL*2) * fringeSize if yPrev > 0 { canvas.Line(x, 0, xPrev, yPrev/2, style) canvas.Line(x, 0, xPrev, yPrev/2) } } canvas.Gend() canvas.End() } Loading @@ -93,37 +93,37 @@ func Skeleton(w http.ResponseWriter, key string, color1, color2 color.RGBA, size lines := 10 fringeSize := size / lines style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Gstyle(style) for xL := 0; xL <= lines; xL++ { x := xL * fringeSize firstY := 0 lastY := (lines) * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) if (xL % 2) != 0 { lastY = lastY - fringeSize/2 firstY = fringeSize / 2 } canvas.Line(x, firstY, x, lastY, style) canvas.Line(x, firstY, x, lastY) } for xL := 0; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := 0 yPrev := (xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x*2, 0, style) canvas.Line(xPrev, yPrev, x*2, 0) } } for xL := -2 * lines; xL <= 2*lines; xL++ { x := xL * fringeSize * 2 style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := lines * fringeSize yPrev := (lines - xL*2) * fringeSize if yPrev > 0 { canvas.Line(x, 0, xPrev, yPrev/2, style) canvas.Line(x, 0, xPrev, yPrev/2) } } canvas.Gend() canvas.End() } Loading
draw/isogrids/labs.go +22 −22 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ import ( "github.com/taironas/tinygraphs/draw" ) // Diagonals builds an image with 10x10 grids of half diagonals // Diagonals builds an image with 10x10 grids of diagonals. func Diagonals(w http.ResponseWriter, key string, color1, color2 color.RGBA, size int) { canvas := svg.New(w) canvas.Start(size, size) Loading @@ -17,33 +17,33 @@ func Diagonals(w http.ResponseWriter, key string, color1, color2 color.RGBA, siz lines := 10 fringeSize := size / lines style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Gstyle(style) for xL := 0; xL <= lines; xL++ { x := xL * fringeSize lastY := (lines) * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Line(x, 0, x, lastY, style) canvas.Line(x, 0, x, lastY) } for xL := 0; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := 0 yPrev := (xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x, 0, style) canvas.Line(xPrev, yPrev, x, 0) } } for xL := -2 * lines; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := lines * fringeSize yPrev := (lines - xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x, 0, style) canvas.Line(xPrev, yPrev, x, 0) } } canvas.Gend() canvas.End() } Loading @@ -55,33 +55,33 @@ func HalfDiagonals(w http.ResponseWriter, key string, color1, color2 color.RGBA, lines := 10 fringeSize := size / lines style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Gstyle(style) for xL := 0; xL <= lines; xL++ { x := xL * fringeSize lastY := (lines) * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Line(x, 0, x, lastY, style) canvas.Line(x, 0, x, lastY) } for xL := 0; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := 0 yPrev := (xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x*2, 0, style) canvas.Line(xPrev, yPrev, x*2, 0) } } for xL := -2 * lines; xL <= 2*lines; xL++ { x := xL * fringeSize * 2 style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := lines * fringeSize yPrev := (lines - xL*2) * fringeSize if yPrev > 0 { canvas.Line(x, 0, xPrev, yPrev/2, style) canvas.Line(x, 0, xPrev, yPrev/2) } } canvas.Gend() canvas.End() } Loading @@ -93,37 +93,37 @@ func Skeleton(w http.ResponseWriter, key string, color1, color2 color.RGBA, size lines := 10 fringeSize := size / lines style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) canvas.Gstyle(style) for xL := 0; xL <= lines; xL++ { x := xL * fringeSize firstY := 0 lastY := (lines) * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) if (xL % 2) != 0 { lastY = lastY - fringeSize/2 firstY = fringeSize / 2 } canvas.Line(x, firstY, x, lastY, style) canvas.Line(x, firstY, x, lastY) } for xL := 0; xL <= 2*lines; xL++ { x := xL * fringeSize style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := 0 yPrev := (xL) * fringeSize if yPrev > 0 { canvas.Line(xPrev, yPrev, x*2, 0, style) canvas.Line(xPrev, yPrev, x*2, 0) } } for xL := -2 * lines; xL <= 2*lines; xL++ { x := xL * fringeSize * 2 style := fmt.Sprintf("stroke:black;stroke-width:2; %s", draw.FillFromRGBA(color2)) xPrev := lines * fringeSize yPrev := (lines - xL*2) * fringeSize if yPrev > 0 { canvas.Line(x, 0, xPrev, yPrev/2, style) canvas.Line(x, 0, xPrev, yPrev/2) } } canvas.Gend() canvas.End() }