-
Notifications
You must be signed in to change notification settings - Fork 65
/
geopattern.go
30 lines (23 loc) · 731 Bytes
/
geopattern.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Package geopattern creates beautiful generative image patterns from a string.
package geopattern
import (
"encoding/base64"
"fmt"
"github.com/pravj/geopattern/pattern"
)
// Generate returns pattern's SVG string
func Generate(args map[string]string) string {
p := pattern.New(args)
return p.SvgStr()
}
// Base64String returns pattern's Base64 encoded string
func Base64String(args map[string]string) string {
svgStr := Generate(args)
base64Str := base64.StdEncoding.EncodeToString([]byte(svgStr))
return base64Str
}
// URIimage returns pattern's uri image string
func URIimage(args map[string]string) string {
base64Str := Base64String(args)
return fmt.Sprintf("url(data:image/svg+xml;base64,%s);", base64Str)
}