Loading draw/isogrids/isogrids.go +0 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ func Isogrids(w http.ResponseWriter, key string, colors []color.RGBA, size, line if (xL % 2) == 0 { x11, y11, x12, y12, _, y13 = left2ndTriangle(xL, yL, fringeSize, distance) // in order to have a perfect hexagon, // we make sure that the previous triangle and this one touch each other in this point. y12 = y3 } else { Loading draw/isogrids/random.go +18 −29 Original line number Diff line number Diff line Loading @@ -14,46 +14,35 @@ func Random(w http.ResponseWriter, key string, colors []color.RGBA, width, heigh canvas.Start(width, height) fringeSize := width / lines distance := distanceTo3rdPoint(fringeSize) fringeSize = distance lines = width / fringeSize for xL := -1; xL <= lines; xL++ { for yL := -1; yL <= lines; yL++ { var x1, x2, x3, y1, y2, y3 int for xL := 0; xL < lines; xL++ { for yL := 0; yL < lines; yL++ { var x1, x2, 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 x1, y1, x2, y2, _, y3 = right1stTriangle(xL, yL, fringeSize, distance) } else { x1 = (xL + 1) * fringeSize x2 = xL * fringeSize x3 = x1 y1 = yL * fringeSize y2 = y1 + fringeSize/2 y3 = (yL + 1) * fringeSize x1, y1, x2, y2, _, y3 = left1stTriangle(xL, yL, fringeSize, distance) } xs := []int{x1, x2, x3} xs := []int{x2, x1, x2} ys := []int{y1, y2, y3} canvas.Polygon(xs, ys, draw.FillFromRGBA(draw.RandomColorFromArray(colors))) var x11, x12, x13, y11, y12, y13 int var x11, x12, y11, y12, y13 int if (xL % 2) == 0 { x11 = (xL + 1) * fringeSize x12 = (xL) * fringeSize x13 = x11 y11 = yL*fringeSize + fringeSize/2 y12 = y11 + fringeSize/2 y13 = (yL+1)*fringeSize + fringeSize/2 x11, y11, x12, y12, _, y13 = left2ndTriangle(xL, yL, fringeSize, distance) // we make sure that the previous triangle and this one touch each other in this point. y12 = y3 } else { x11 = (xL) * fringeSize x12 = (xL + 1) * fringeSize x13 = x11 y11 = yL*fringeSize + fringeSize/2 x11, y11, x12, y12, _, y13 = right2ndTriangle(xL, yL, fringeSize, distance) // we make sure that the previous triangle and this one touch each other in this point. y12 = y1 + fringeSize y13 = (yL+1)*fringeSize + fringeSize/2 } xs1 := []int{x11, x12, x13} xs1 := []int{x12, x11, x12} ys1 := []int{y11, y12, y13} canvas.Polygon(xs1, ys1, draw.FillFromRGBA(draw.RandomColorFromArray(colors))) } Loading Loading
draw/isogrids/isogrids.go +0 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ func Isogrids(w http.ResponseWriter, key string, colors []color.RGBA, size, line if (xL % 2) == 0 { x11, y11, x12, y12, _, y13 = left2ndTriangle(xL, yL, fringeSize, distance) // in order to have a perfect hexagon, // we make sure that the previous triangle and this one touch each other in this point. y12 = y3 } else { Loading
draw/isogrids/random.go +18 −29 Original line number Diff line number Diff line Loading @@ -14,46 +14,35 @@ func Random(w http.ResponseWriter, key string, colors []color.RGBA, width, heigh canvas.Start(width, height) fringeSize := width / lines distance := distanceTo3rdPoint(fringeSize) fringeSize = distance lines = width / fringeSize for xL := -1; xL <= lines; xL++ { for yL := -1; yL <= lines; yL++ { var x1, x2, x3, y1, y2, y3 int for xL := 0; xL < lines; xL++ { for yL := 0; yL < lines; yL++ { var x1, x2, 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 x1, y1, x2, y2, _, y3 = right1stTriangle(xL, yL, fringeSize, distance) } else { x1 = (xL + 1) * fringeSize x2 = xL * fringeSize x3 = x1 y1 = yL * fringeSize y2 = y1 + fringeSize/2 y3 = (yL + 1) * fringeSize x1, y1, x2, y2, _, y3 = left1stTriangle(xL, yL, fringeSize, distance) } xs := []int{x1, x2, x3} xs := []int{x2, x1, x2} ys := []int{y1, y2, y3} canvas.Polygon(xs, ys, draw.FillFromRGBA(draw.RandomColorFromArray(colors))) var x11, x12, x13, y11, y12, y13 int var x11, x12, y11, y12, y13 int if (xL % 2) == 0 { x11 = (xL + 1) * fringeSize x12 = (xL) * fringeSize x13 = x11 y11 = yL*fringeSize + fringeSize/2 y12 = y11 + fringeSize/2 y13 = (yL+1)*fringeSize + fringeSize/2 x11, y11, x12, y12, _, y13 = left2ndTriangle(xL, yL, fringeSize, distance) // we make sure that the previous triangle and this one touch each other in this point. y12 = y3 } else { x11 = (xL) * fringeSize x12 = (xL + 1) * fringeSize x13 = x11 y11 = yL*fringeSize + fringeSize/2 x11, y11, x12, y12, _, y13 = right2ndTriangle(xL, yL, fringeSize, distance) // we make sure that the previous triangle and this one touch each other in this point. y12 = y1 + fringeSize y13 = (yL+1)*fringeSize + fringeSize/2 } xs1 := []int{x11, x12, x13} xs1 := []int{x12, x11, x12} ys1 := []int{y11, y12, y13} canvas.Polygon(xs1, ys1, draw.FillFromRGBA(draw.RandomColorFromArray(colors))) } Loading