Loading README.md +7 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,13 @@ You can set the HTML source of the image to point directly to **tinygraphs.com**  * **lines** You can specify the number of lines that an isogrid can have using the `lines`parameter. **Default** parameter is **6** `tinygraphs.com/isogrids/hello?lines=4`  Organization ===== Loading controllers/isogrids/isogrids.go +5 −4 Original line number Diff line number Diff line Loading @@ -30,10 +30,7 @@ func Isogrids(w http.ResponseWriter, r *http.Request) { key = fmt.Sprintf("%x", h.Sum(nil)[:]) colorMap := colors.MapOfColorThemes() size := extract.Size(r) numColors := extract.NumColors(r) bg, fg := extract.ExtraColors(r, colorMap) theme := extract.Theme(r) if val, ok := colorMap[theme]; ok { bg = val[0] Loading @@ -43,6 +40,7 @@ func Isogrids(w http.ResponseWriter, r *http.Request) { var colors []color.RGBA if theme != "base" { if _, ok := colorMap[theme]; ok { numColors := extract.NumColors(r) colors = append(colors, colorMap[theme][0:numColors]...) } else { colors = append(colors, colorMap["base"]...) Loading @@ -51,6 +49,9 @@ func Isogrids(w http.ResponseWriter, r *http.Request) { colors = append(colors, bg, fg) } size := extract.Size(r) lines := extract.Lines(r) write.ImageSVG(w) isogrids.Isogrids(w, key, colors, size) isogrids.Isogrids(w, key, colors, size, lines) } draw/isogrids/isogrids.go +1 −2 Original line number Diff line number Diff line Loading @@ -130,11 +130,10 @@ func RandomMirror(w http.ResponseWriter, key string, colors []color.RGBA, size i } // Isogrids builds an image with 10x10 grids of half diagonals func Isogrids(w http.ResponseWriter, key string, colors []color.RGBA, size int) { func Isogrids(w http.ResponseWriter, key string, colors []color.RGBA, size, lines int) { canvas := svg.New(w) canvas.Start(size, size) lines := 10 fringeSize := size / lines // triangle grid here: Loading extract/extract.go +14 −0 Original line number Diff line number Diff line Loading @@ -130,3 +130,17 @@ func Hexalines(r *http.Request) int64 { } return 6 } // Lines return the value of the lines parameter in the http.Request. // Default value is 6 func Lines(r *http.Request) int { s := strings.ToLower(r.FormValue("lines")) if len(s) > 0 { if n, err := strconv.ParseInt(s, 0, 64); err == nil { if n > 0 { return int(n) } } } return 6 } Loading
README.md +7 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,13 @@ You can set the HTML source of the image to point directly to **tinygraphs.com**  * **lines** You can specify the number of lines that an isogrid can have using the `lines`parameter. **Default** parameter is **6** `tinygraphs.com/isogrids/hello?lines=4`  Organization ===== Loading
controllers/isogrids/isogrids.go +5 −4 Original line number Diff line number Diff line Loading @@ -30,10 +30,7 @@ func Isogrids(w http.ResponseWriter, r *http.Request) { key = fmt.Sprintf("%x", h.Sum(nil)[:]) colorMap := colors.MapOfColorThemes() size := extract.Size(r) numColors := extract.NumColors(r) bg, fg := extract.ExtraColors(r, colorMap) theme := extract.Theme(r) if val, ok := colorMap[theme]; ok { bg = val[0] Loading @@ -43,6 +40,7 @@ func Isogrids(w http.ResponseWriter, r *http.Request) { var colors []color.RGBA if theme != "base" { if _, ok := colorMap[theme]; ok { numColors := extract.NumColors(r) colors = append(colors, colorMap[theme][0:numColors]...) } else { colors = append(colors, colorMap["base"]...) Loading @@ -51,6 +49,9 @@ func Isogrids(w http.ResponseWriter, r *http.Request) { colors = append(colors, bg, fg) } size := extract.Size(r) lines := extract.Lines(r) write.ImageSVG(w) isogrids.Isogrids(w, key, colors, size) isogrids.Isogrids(w, key, colors, size, lines) }
draw/isogrids/isogrids.go +1 −2 Original line number Diff line number Diff line Loading @@ -130,11 +130,10 @@ func RandomMirror(w http.ResponseWriter, key string, colors []color.RGBA, size i } // Isogrids builds an image with 10x10 grids of half diagonals func Isogrids(w http.ResponseWriter, key string, colors []color.RGBA, size int) { func Isogrids(w http.ResponseWriter, key string, colors []color.RGBA, size, lines int) { canvas := svg.New(w) canvas.Start(size, size) lines := 10 fringeSize := size / lines // triangle grid here: Loading
extract/extract.go +14 −0 Original line number Diff line number Diff line Loading @@ -130,3 +130,17 @@ func Hexalines(r *http.Request) int64 { } return 6 } // Lines return the value of the lines parameter in the http.Request. // Default value is 6 func Lines(r *http.Request) int { s := strings.ToLower(r.FormValue("lines")) if len(s) > 0 { if n, err := strconv.ParseInt(s, 0, 64); err == nil { if n > 0 { return int(n) } } } return 6 }