Ejemplo n.º 1
0
func lettericonHandler(w http.ResponseWriter, r *http.Request) {
	charParam, col, size := lettericon.ParseIconPath(r.URL.Path)
	if charParam != "" {
		w.Header().Add("Content-Type", "image/png")
		lettericon.Render(charParam, col, size, w)
	} else {
		writeAPIError(w, 400, errors.New("wrong format for lettericons/ path, must look like lettericons/M-144-EFC25D.png"), true)
	}
}
Ejemplo n.º 2
0
func main() {
	flag.Parse()

	f, err := os.Create("out.png")
	if err != nil {
		log.Println(err)
		os.Exit(1)
	}
	defer f.Close()

	col, err := lettericon.ColorFromHex(*iconColor)
	if err != nil {
		log.Println(err)
		os.Exit(1)
	}

	err = lettericon.Render(*letter, col, *width, f)
	if err != nil {
		os.Exit(1)
	}
	fmt.Println("Wrote out.png OK.")
}