mirror of
https://codeberg.org/Codeberg/avatars.git
synced 2023-08-10 21:12:50 +03:00
make go happy
This commit is contained in:
parent
265ab9223a
commit
0acd3d10ec
4
Makefile
4
Makefile
@ -16,10 +16,6 @@ all : ${TARGETS}
|
|||||||
${GOPATH}/bin/avatar : main.go ${GOROOT}/bin/go
|
${GOPATH}/bin/avatar : main.go ${GOROOT}/bin/go
|
||||||
go build -o $@ $<
|
go build -o $@ $<
|
||||||
|
|
||||||
${GOROOT}/bin/go :
|
|
||||||
mkdir -p ${GOROOT}/Downloads
|
|
||||||
wget -c --no-verbose --directory-prefix=${GOROOT}/Downloads https://dl.google.com/go/${GOTAR}
|
|
||||||
tar xfz ${GOROOT}/Downloads/${GOTAR} -C ${BUILDDIR}
|
|
||||||
|
|
||||||
deployment : deploy-avatar
|
deployment : deploy-avatar
|
||||||
|
|
||||||
|
149
main.go
149
main.go
@ -1,26 +1,29 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"math/bits"
|
"math/bits"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
fmt.Println("please specify a seed string")
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Println(makeAvatar(os.Args[1]))
|
fmt.Println(makeAvatar(os.Args[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeAvatar (seed_string string) string {
|
func makeAvatar(seedString string) string {
|
||||||
var seed uint64 = 0
|
var seed uint64
|
||||||
for _, c := range []byte(seed_string) {
|
for _, c := range []byte(seedString) {
|
||||||
seed = bits.RotateLeft64(seed, 8)
|
seed = bits.RotateLeft64(seed, 8)
|
||||||
seed ^= uint64(c)
|
seed ^= uint64(c)
|
||||||
}
|
}
|
||||||
return femaleAvatar(seed)
|
return femaleAvatar(seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on TypeScript DiceBear Avatars, which in turn were inspired by 8biticon avatars:
|
* Based on TypeScript DiceBear Avatars, which in turn were inspired by 8biticon avatars:
|
||||||
* (MIT License, Copyright (c) 2012 Plastic Jam, Copyright (c) 2019 DiceBear)
|
* (MIT License, Copyright (c) 2012 Plastic Jam, Copyright (c) 2019 DiceBear)
|
||||||
@ -31,32 +34,31 @@ type LCG struct {
|
|||||||
seed uint64
|
seed uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g * LCG) random () uint32 {
|
func (g *LCG) random() uint32 {
|
||||||
/* Linear Congruent Generator, POSIX/glibc [de]rand48 setting, bits [47..0] are output bits */
|
/* Linear Congruent Generator, POSIX/glibc [de]rand48 setting, bits [47..0] are output bits */
|
||||||
g.seed = (25214903917 * g.seed + 11) % 281474976710656
|
g.seed = (25214903917*g.seed + 11) % 281474976710656
|
||||||
return uint32(g.seed)
|
return uint32(g.seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g * LCG) binomial (p float32) bool {
|
func (g *LCG) binomial(p float32) bool {
|
||||||
/* Sample from Binomial distribution with probability p */
|
/* Sample from Binomial distribution with probability p */
|
||||||
var sample = float32(g.random()) * float32(1.0 / 4294967295.0)
|
var sample = float32(g.random()) * float32(1.0/4294967295.0)
|
||||||
return sample > p
|
return sample > p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g * LCG) pickone (s []string) string {
|
func (g *LCG) pickOne(s []string) string {
|
||||||
/* Pick one element from list */
|
/* Pick one element from list */
|
||||||
var N uint32 = uint32(len(s))
|
var N = uint32(len(s))
|
||||||
return s[g.random() % N]
|
return s[g.random()%N]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g * LCG) pickoneFloat (s []float32) float32 {
|
func (g *LCG) pickOneFloat(s []float32) float32 {
|
||||||
/* Pick one element from list - float version*/
|
/* Pick one element from list - float version*/
|
||||||
var N uint32 = uint32(len(s))
|
var N = uint32(len(s))
|
||||||
return s[g.random() % N]
|
return s[g.random()%N]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *LCG) pickAorB(p float32, a string, b string) string {
|
||||||
func (g * LCG) pick_a_or_b (p float32, a string, b string) string {
|
|
||||||
/* Pick a or b with probability p of picking a */
|
/* Pick a or b with probability p of picking a */
|
||||||
if g.binomial(p) {
|
if g.binomial(p) {
|
||||||
return a
|
return a
|
||||||
@ -64,7 +66,7 @@ func (g * LCG) pick_a_or_b (p float32, a string, b string) string {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func LinearCongruentialGenerator (seed uint64) * LCG {
|
func LinearCongruentialGenerator(seed uint64) *LCG {
|
||||||
g := new(LCG)
|
g := new(LCG)
|
||||||
g.seed = seed
|
g.seed = seed
|
||||||
return g
|
return g
|
||||||
@ -76,27 +78,27 @@ type COLOR struct {
|
|||||||
b uint8
|
b uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func Color (s string) * COLOR {
|
func Color(s string) *COLOR {
|
||||||
c := new(COLOR)
|
c := new(COLOR)
|
||||||
fmt.Sscanf(s, "#%02x%02x%02x", c.r, c.g, c.b)
|
fmt.Sscanf(s, "#%02x%02x%02x", c.r, c.g, c.b)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func add255 (x uint8, y uint8) uint8 {
|
func add255(x uint8, y uint8) uint8 {
|
||||||
if x < 255 - y {
|
if x < 255-y {
|
||||||
return x + y
|
return x + y
|
||||||
}
|
}
|
||||||
return 255
|
return 255
|
||||||
}
|
}
|
||||||
|
|
||||||
func sub255 (x uint8, y uint8) uint8 {
|
func sub255(x uint8, y uint8) uint8 {
|
||||||
if x > y {
|
if x > y {
|
||||||
return x - y
|
return x - y
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c * COLOR) brighterOrDarkerThan (ref COLOR, delta uint8) string {
|
func (c *COLOR) brighterOrDarkerThan(ref COLOR, delta uint8) string {
|
||||||
/* XXX FIXME: THIS IS PROBABLY NOT CORRECT. Need to look into original implementation. */
|
/* XXX FIXME: THIS IS PROBABLY NOT CORRECT. Need to look into original implementation. */
|
||||||
if true {
|
if true {
|
||||||
return fmt.Sprintf("#%02x%02x%02x", add255(c.r, delta), add255(c.g, delta), add255(c.b, delta))
|
return fmt.Sprintf("#%02x%02x%02x", add255(c.r, delta), add255(c.g, delta), add255(c.b, delta))
|
||||||
@ -104,33 +106,33 @@ func (c * COLOR) brighterOrDarkerThan (ref COLOR, delta uint8) string {
|
|||||||
return ref.darkerThan(ref, delta)
|
return ref.darkerThan(ref, delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c * COLOR) darkerThan (ref COLOR, delta uint8) string {
|
func (c *COLOR) darkerThan(ref COLOR, delta uint8) string {
|
||||||
/* XXX FIXME: THIS IS NOT CORRECT. The original implementation does darkening in HSV space.
|
/* XXX FIXME: THIS IS NOT CORRECT. The original implementation does darkening in HSV space.
|
||||||
* cf. https://github.com/DiceBear/avatars/blob/master/packages/avatars/src/color.ts
|
* cf. https://github.com/DiceBear/avatars/blob/master/packages/avatars/src/color.ts
|
||||||
*/
|
*/
|
||||||
return fmt.Sprintf("#%02x%02x%02x", sub255(c.r, delta), sub255(c.g, delta), sub255(c.b, delta))
|
return fmt.Sprintf("#%02x%02x%02x", sub255(c.r, delta), sub255(c.g, delta), sub255(c.b, delta))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c COLOR) withAlpha (alpha float32) string {
|
func (c COLOR) withAlpha(alpha float32) string {
|
||||||
return fmt.Sprintf("#%02x%02x%02x", c.r, c.g, c.b, uint8(255 * alpha))
|
return fmt.Sprintf("#%02x%02x%02x", c.r, c.g, c.b, uint8(255*alpha))
|
||||||
}
|
}
|
||||||
|
|
||||||
func maleAvatar (seed uint64) string {
|
func maleAvatar(seed uint64) string {
|
||||||
var g = LinearCongruentialGenerator(seed)
|
var g = LinearCongruentialGenerator(seed)
|
||||||
var skinColor = g.pickone([]string { "#FFDBAC", "#F5CFA0", "#EAC393", "#E0B687", "#CB9E6E", "#B68655", "#A26D3D", "#8D5524" });
|
var skinColor = g.pickOne([]string{"#FFDBAC", "#F5CFA0", "#EAC393", "#E0B687", "#CB9E6E", "#B68655", "#A26D3D", "#8D5524"})
|
||||||
var hairColor = Color(g.pickone([]string { "#090806", "#2c222b", "#71635a", "#b7a69e", "#b89778", "#a56b46", "#b55239", "#8d4a43",
|
var hairColor = Color(g.pickOne([]string{"#090806", "#2c222b", "#71635a", "#b7a69e", "#b89778", "#a56b46", "#b55239", "#8d4a43",
|
||||||
"#91553d", "#533d32", "#3b3024", "#554838", "#4e433f", "#504444", "#6a4e42", "#a7856a", "#977961" })).brighterOrDarkerThan(*Color(skinColor), 17)
|
"#91553d", "#533d32", "#3b3024", "#554838", "#4e433f", "#504444", "#6a4e42", "#a7856a", "#977961"})).brighterOrDarkerThan(*Color(skinColor), 17)
|
||||||
var eyesColor = g.pickone([]string { "#76778b", "#697b94", "#647b90", "#5b7c8b", "#588387" })
|
var eyesColor = g.pickOne([]string{"#76778b", "#697b94", "#647b90", "#5b7c8b", "#588387"})
|
||||||
var eyebrowsColor = Color(Color(hairColor).darkerThan(*Color(skinColor), 7)).darkerThan(*Color(hairColor), 10)
|
var eyebrowsColor = Color(Color(hairColor).darkerThan(*Color(skinColor), 7)).darkerThan(*Color(hairColor), 10)
|
||||||
var mustacheColor = Color(Color(hairColor).darkerThan(*Color(skinColor), 7)).withAlpha(g.pickoneFloat([]float32 { 1, 0.75, 0.5 }))
|
var mustacheColor = Color(Color(hairColor).darkerThan(*Color(skinColor), 7)).withAlpha(g.pickOneFloat([]float32{1, 0.75, 0.5}))
|
||||||
var mouthColor = Color(g.pickone([]string { "#eec1ad", "#dbac98", "#d29985" })).brighterOrDarkerThan(*Color(skinColor), 10)
|
var mouthColor = Color(g.pickOne([]string{"#eec1ad", "#dbac98", "#d29985"})).brighterOrDarkerThan(*Color(skinColor), 10)
|
||||||
var glassesColor = g.pickone([]string { "#5f705c", "#43677d", "#5e172d", "#ffb67a", "#a04b5d", "#191919", "#323232", "#4b4b4b" })
|
var glassesColor = g.pickOne([]string{"#5f705c", "#43677d", "#5e172d", "#ffb67a", "#a04b5d", "#191919", "#323232", "#4b4b4b"})
|
||||||
var clothesColor = g.pickone([]string { "#5bc0de", "#5cb85c", "#428bca", "#03396c", "#005b96", "#6497b1", "#1b85b8", "#5a5255", "#559e83", "#ae5a41", "#c3cb71", "#666547", "#ffe28a" })
|
var clothesColor = g.pickOne([]string{"#5bc0de", "#5cb85c", "#428bca", "#03396c", "#005b96", "#6497b1", "#1b85b8", "#5a5255", "#559e83", "#ae5a41", "#c3cb71", "#666547", "#ffe28a"})
|
||||||
var hatColor = g.pickone([]string { "#18293b", "#2e1e05", "#989789", "#3d6ba7", "#517459", "#a62116" });
|
var hatColor = g.pickOne([]string{"#18293b", "#2e1e05", "#989789", "#3d6ba7", "#517459", "#a62116"})
|
||||||
|
|
||||||
var mood = ""
|
var mood = ""
|
||||||
if mood == "" {
|
if mood == "" {
|
||||||
mood = g.pickone([]string { "sad", "happy", "surprised" })
|
mood = g.pickOne([]string{"sad", "happy", "surprised"})
|
||||||
}
|
}
|
||||||
var mouth string
|
var mouth string
|
||||||
if mood == "sad" {
|
if mood == "sad" {
|
||||||
@ -149,12 +151,12 @@ func maleAvatar (seed uint64) string {
|
|||||||
"<path d='M9 13v1h1v-1H9z' fill='${mouthColor}'/>"
|
"<path d='M9 13v1h1v-1H9z' fill='${mouthColor}'/>"
|
||||||
}
|
}
|
||||||
|
|
||||||
var s = strings.Join([]string {
|
var s = strings.Join([]string{
|
||||||
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='isolation:isolate' viewBox='0 0 20 20' version='1.1' shape-rendering='crispEdges'>",
|
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='isolation:isolate' viewBox='0 0 20 20' version='1.1' shape-rendering='crispEdges'>",
|
||||||
// Head
|
// Head
|
||||||
"<path d='M8 15v1H4v1H3v3h14v-3h-1v-1h-4v-1h3v-1h1v-1h1v-3h1V7h-1V4h-1V3h-1V2H5v1H4v1H3v3H2v3h1v3h1v1h1v1h3z' fill='${skinColor}'/><path d='M5 15v-1H4v-1H3v-3H2V7h1V4h1V3h1V2h10v1h1v1h1v3h1v3h-1v3h-1v1h-1v1H5z' fill='#FFF' fill-opacity='.1'/>",
|
"<path d='M8 15v1H4v1H3v3h14v-3h-1v-1h-4v-1h3v-1h1v-1h1v-3h1V7h-1V4h-1V3h-1V2H5v1H4v1H3v3H2v3h1v3h1v1h1v1h3z' fill='${skinColor}'/><path d='M5 15v-1H4v-1H3v-3H2V7h1V4h1V3h1V2h10v1h1v1h1v3h1v3h-1v3h-1v1h-1v1H5z' fill='#FFF' fill-opacity='.1'/>",
|
||||||
// Eyes
|
// Eyes
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M5 9V7h3v2H5zm7-2h3v2h-3V7z' fill='#FFF'/><path d='M7 8v1h1V8H7zm7 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
"<path d='M5 9V7h3v2H5zm7-2h3v2h-3V7z' fill='#FFF'/><path d='M7 8v1h1V8H7zm7 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
||||||
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M6 8h1v1H6V8zm7 1V8h1v1h-1z' fill='${eyesColor}'/>",
|
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M6 8h1v1H6V8zm7 1V8h1v1h-1z' fill='${eyesColor}'/>",
|
||||||
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M7 8h1v1H7V8zm5 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M7 8h1v1H7V8zm5 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
||||||
@ -170,7 +172,7 @@ func maleAvatar (seed uint64) string {
|
|||||||
"<path d='M6 7h1v2H5V8h1V7zm7 0h1v2h-2V8h1V7z' fill='#FFF'/><path d='M7 7v1H6v1h2V7H7zm7 0v1h-1v1h2V7h-1z' fill='${eyesColor}'/><path d='M7 7v1h1V7H7zM6 8v1h1V8H6zm8-1v1h1V7h-1zm-1 1v1h1V8h-1z' fill='#FFF' fill-opacity='.5'/>",
|
"<path d='M6 7h1v2H5V8h1V7zm7 0h1v2h-2V8h1V7z' fill='#FFF'/><path d='M7 7v1H6v1h2V7H7zm7 0v1h-1v1h2V7h-1z' fill='${eyesColor}'/><path d='M7 7v1h1V7H7zM6 8v1h1V8H6zm8-1v1h1V7h-1zm-1 1v1h1V8h-1z' fill='#FFF' fill-opacity='.5'/>",
|
||||||
}),
|
}),
|
||||||
// Eyebrows
|
// Eyebrows
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M7 5v1H5v1H4V6h1V5h2zm7 0v1h-2v1h-1V6h1V5h2z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M7 5v1H5v1H4V6h1V5h2zm7 0v1h-2v1h-1V6h1V5h2z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
"<path d='M8 4v1H7v1H5V5h2V4h1zm4 0h1v1h2v1h-2V5h-1V4z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M8 4v1H7v1H5V5h2V4h1zm4 0h1v1h2v1h-2V5h-1V4z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
"<path d='M6 5h3v2H8V6H6V5zm5 0h3v1h-2v1h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M6 5h3v2H8V6H6V5zm5 0h3v1h-2v1h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
@ -186,8 +188,8 @@ func maleAvatar (seed uint64) string {
|
|||||||
"<path d='M4 7V6h1V5h1v1H5v1H4zm10-2h1v1h1v1h-1V6h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M4 7V6h1V5h1v1H5v1H4zm10-2h1v1h1v1h-1V6h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
}),
|
}),
|
||||||
// Mustache (50% chance)
|
// Mustache (50% chance)
|
||||||
g.pick_a_or_b(0.5,
|
g.pickAorB(0.5,
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M3 10v3h1v1h1v1h10v-1h1v-1h1v-3h-3v1H6v-1H3z' id='Path' fill='${mustacheColor}' fill-opacity='${mustacheColor.alpha}'/>",
|
"<path d='M3 10v3h1v1h1v1h10v-1h1v-1h1v-3h-3v1H6v-1H3z' id='Path' fill='${mustacheColor}' fill-opacity='${mustacheColor.alpha}'/>",
|
||||||
"<path d='M3 13h1v1h1v1h10v-1h1v-1h1v-3h-1v1h-1v1H5v-1H4v-1H3v3z' id='Path' fill='${mustacheColor}' fill-opacity='${mustacheColor.alpha}'/>",
|
"<path d='M3 13h1v1h1v1h10v-1h1v-1h1v-3h-1v1h-1v1H5v-1H4v-1H3v3z' id='Path' fill='${mustacheColor}' fill-opacity='${mustacheColor.alpha}'/>",
|
||||||
"<path d='M3 11v2h1v1h1v1h10v-1h1v-1h1v-2H3z' id='Path' fill='${mustacheColor}' fill-opacity='${mustacheColor.alpha}'/>",
|
"<path d='M3 11v2h1v1h1v1h10v-1h1v-1h1v-2H3z' id='Path' fill='${mustacheColor}' fill-opacity='${mustacheColor.alpha}'/>",
|
||||||
@ -197,8 +199,8 @@ func maleAvatar (seed uint64) string {
|
|||||||
// Mouth
|
// Mouth
|
||||||
mouth,
|
mouth,
|
||||||
// Glasses (25% chance)
|
// Glasses (25% chance)
|
||||||
g.pick_a_or_b(0.25,
|
g.pickAorB(0.25,
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M5 7h3v3H5V7zm7 0h3v3h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M12 10V7h3v3h-3zm-1-4v1H9V6H4v1H3v1h1v3h5V8h2v3h5V8h1V7h-1V6h-5zm-6 4V7h3v3H5z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M5 7h3v3H5V7zm7 0h3v3h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M12 10V7h3v3h-3zm-1-4v1H9V6H4v1H3v1h1v3h5V8h2v3h5V8h1V7h-1V6h-5zm-6 4V7h3v3H5z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
||||||
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M5 7v2h3V7H5zM4 6v1H3v1h1v1h1v1h3V9h1V8h2v1h1v1h3V9h1V8h1V7h-1V6h-5v1H9V6H4zm8 1v2h3V7h-3z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M5 7v2h3V7H5zM4 6v1H3v1h1v1h1v1h3V9h1V8h2v1h1v1h3V9h1V8h1V7h-1V6h-5v1H9V6H4zm8 1v2h3V7h-3z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
||||||
"<path d='M5 8h3v1H5V8zm7 0h3v1h-3V8z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 8h1v1H7V8zm7 0h1v1h-1V8z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M5 8v1h3V8H5zM3 7v1h1v1h1v1h3V9h1V8h2v1h1v1h3V9h1V8h1V7H3zm9 1v1h3V8h-3z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7v1h1V7H3zm6 0v1h2V7H9zm7 0v1h1V7h-1z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M5 8h3v1H5V8zm7 0h3v1h-3V8z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 8h1v1H7V8zm7 0h1v1h-1V8z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M5 8v1h3V8H5zM3 7v1h1v1h1v1h3V9h1V8h2v1h1v1h3V9h1V8h1V7H3zm9 1v1h3V8h-3z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7v1h1V7H3zm6 0v1h2V7H9zm7 0v1h1V7h-1z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
||||||
@ -208,7 +210,7 @@ func maleAvatar (seed uint64) string {
|
|||||||
}),
|
}),
|
||||||
""),
|
""),
|
||||||
// Clothes
|
// Clothes
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M3 20v-3h1v-1h4v-1h4v1h4v1h1v3H3z' fill='${clothesColor}'/><path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='#FFF' fill-opacity='.2'/><path d='M12 19v-1h3v1h-3z' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M3 20v-3h1v-1h4v-1h4v1h4v1h1v3H3z' fill='${clothesColor}'/><path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='#FFF' fill-opacity='.2'/><path d='M12 19v-1h3v1h-3z' fill='#FFF' fill-opacity='.2'/>",
|
||||||
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/><path d='M5 20v-2h1v-1h8v1h1v2h-2v-1h-2v1H9v-1H7v1H5z' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/><path d='M5 20v-2h1v-1h8v1h1v2h-2v-1h-2v1H9v-1H7v1H5z' fill='#FFF' fill-opacity='.2'/>",
|
||||||
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/><path d='M8 16H4v1H3v3h14v-3h-1v-1h-4v1h1v1h-1v1h-1v-1H9v1H8v-1H7v-1h1v-1z' fill='#FFF' fill-opacity='.2'/><path d='M9 16v1h2v-1H9z' fill='#FFF'/>",
|
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/><path d='M8 16H4v1H3v3h14v-3h-1v-1h-4v1h1v1h-1v1h-1v-1H9v1H8v-1H7v-1h1v-1z' fill='#FFF' fill-opacity='.2'/><path d='M9 16v1h2v-1H9z' fill='#FFF'/>",
|
||||||
@ -224,8 +226,8 @@ func maleAvatar (seed uint64) string {
|
|||||||
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/>",
|
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/>",
|
||||||
}),
|
}),
|
||||||
// Hair (95% chance)
|
// Hair (95% chance)
|
||||||
g.pick_a_or_b(0.95,
|
g.pickAorB(0.95,
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M3 3v2h1V4h1V3h10v1h1v1h1V3h-1V2H4v1H3z' fill='${hairColor}'/>",
|
"<path d='M3 3v2h1V4h1V3h10v1h1v1h1V3h-1V2H4v1H3z' fill='${hairColor}'/>",
|
||||||
"<path d='M5 2h10v1h1v1h1v3h-1V6h-1V5h-1V4h-4v1H8v1H7v1H4V6H3V4h1V3h1V2z' fill='${hairColor}'/>",
|
"<path d='M5 2h10v1h1v1h1v3h-1V6h-1V5h-1V4h-4v1H8v1H7v1H4V6H3V4h1V3h1V2z' fill='${hairColor}'/>",
|
||||||
"<path d='M3 6h1V4h1V3h2v1h1v1h4V4h1V3h2v1h1v2h1V4h-1V3h-1V2H5v1H4v1H3v2z' fill='${hairColor}'/>",
|
"<path d='M3 6h1V4h1V3h2v1h1v1h4V4h1V3h2v1h1v2h1V4h-1V3h-1V2H5v1H4v1H3v2z' fill='${hairColor}'/>",
|
||||||
@ -242,8 +244,8 @@ func maleAvatar (seed uint64) string {
|
|||||||
}),
|
}),
|
||||||
""),
|
""),
|
||||||
// Hat (5% chance)
|
// Hat (5% chance)
|
||||||
g.pick_a_or_b(0.05,
|
g.pickAorB(0.05,
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M4 0v2H2v2h16V2h-2V0H4z' fill='${hatColor}'/>",
|
"<path d='M4 0v2H2v2h16V2h-2V0H4z' fill='${hatColor}'/>",
|
||||||
"<path d='M4 3H2v1h16V3h-2V0H4v3z' fill='${hatColor}'/>",
|
"<path d='M4 3H2v1h16V3h-2V0H4v3z' fill='${hatColor}'/>",
|
||||||
"<path d='M2 2v2h16V2h-1V1h-1V0H4v1H3v1H2z' fill='${hatColor}'/>",
|
"<path d='M2 2v2h16V2h-1V1h-1V0H4v1H3v1H2z' fill='${hatColor}'/>",
|
||||||
@ -275,25 +277,25 @@ func maleAvatar (seed uint64) string {
|
|||||||
return strings.NewReplacer(m...).Replace(s)
|
return strings.NewReplacer(m...).Replace(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func femaleAvatar (seed uint64) string {
|
func femaleAvatar(seed uint64) string {
|
||||||
var g = LinearCongruentialGenerator(seed)
|
var g = LinearCongruentialGenerator(seed)
|
||||||
|
|
||||||
var skinColor = g.pickone([]string { "#FFDBAC", "#F5CFA0", "#EAC393", "#E0B687", "#CB9E6E", "#B68655", "#A26D3D", "#8D5524" })
|
var skinColor = g.pickOne([]string{"#FFDBAC", "#F5CFA0", "#EAC393", "#E0B687", "#CB9E6E", "#B68655", "#A26D3D", "#8D5524"})
|
||||||
var hairColor = Color(g.pickone([]string { "#090806", "#2c222b", "#71635a", "#b7a69e", "#d6c4c2", "#cabfb1", "#dcd0ba", "#fff5e1",
|
var hairColor = Color(g.pickOne([]string{"#090806", "#2c222b", "#71635a", "#b7a69e", "#d6c4c2", "#cabfb1", "#dcd0ba", "#fff5e1",
|
||||||
"#e6cea8", "#e5c8a8", "#debc99", "#b89778", "#a56b46", "#b55239", "#8d4a43", "#91553d",
|
"#e6cea8", "#e5c8a8", "#debc99", "#b89778", "#a56b46", "#b55239", "#8d4a43", "#91553d",
|
||||||
"#533d32", "#3b3024", "#554838", "#4e433f", "#504444", "#6a4e42", "#a7856a", "#977961" })).brighterOrDarkerThan(*Color(skinColor), 17)
|
"#533d32", "#3b3024", "#554838", "#4e433f", "#504444", "#6a4e42", "#a7856a", "#977961"})).brighterOrDarkerThan(*Color(skinColor), 17)
|
||||||
var eyesColor = g.pickone([]string { "#76778b", "#697b94", "#647b90", "#5b7c8b", "#588387" })
|
var eyesColor = g.pickOne([]string{"#76778b", "#697b94", "#647b90", "#5b7c8b", "#588387"})
|
||||||
var eyebrowsColor = Color(Color(hairColor).darkerThan(*Color(skinColor), 7)).darkerThan(*Color(hairColor), 10)
|
var eyebrowsColor = Color(Color(hairColor).darkerThan(*Color(skinColor), 7)).darkerThan(*Color(hairColor), 10)
|
||||||
var accessoriesColor = g.pickone([]string { "#daa520", "#ffd700", "#eee8aa", "#fafad2", "#d3d3d3", "#a9a9a9" })
|
var accessoriesColor = g.pickOne([]string{"#daa520", "#ffd700", "#eee8aa", "#fafad2", "#d3d3d3", "#a9a9a9"})
|
||||||
var mouthColor = Color(g.pickone([]string { "#dbac98", "#d29985", "#c98276", "#e35d6a", "#e32153", "#de0f0d" })).brighterOrDarkerThan(*Color(skinColor), 10)
|
var mouthColor = Color(g.pickOne([]string{"#dbac98", "#d29985", "#c98276", "#e35d6a", "#e32153", "#de0f0d"})).brighterOrDarkerThan(*Color(skinColor), 10)
|
||||||
var glassesColor = g.pickone([]string { "#5f705c", "#43677d", "#5e172d", "#ffb67a", "#a04b5d", "#191919", "#323232", "#4b4b4b" });
|
var glassesColor = g.pickOne([]string{"#5f705c", "#43677d", "#5e172d", "#ffb67a", "#a04b5d", "#191919", "#323232", "#4b4b4b"})
|
||||||
var clothesColor = g.pickone([]string { "#d11141", "#00b159", "#00aedb", "#f37735", "#ffc425", "#740001", "#ae0001", "#eeba30",
|
var clothesColor = g.pickOne([]string{"#d11141", "#00b159", "#00aedb", "#f37735", "#ffc425", "#740001", "#ae0001", "#eeba30",
|
||||||
"#96ceb4", "#ffeead", "#ff6f69", "#ffcc5c", "#88d8b0" })
|
"#96ceb4", "#ffeead", "#ff6f69", "#ffcc5c", "#88d8b0"})
|
||||||
var hatColor = g.pickone([]string { "#cc6192", "#2663a3", "#a62116", "#3d8a6b", "#614f8a" })
|
var hatColor = g.pickOne([]string{"#cc6192", "#2663a3", "#a62116", "#3d8a6b", "#614f8a"})
|
||||||
|
|
||||||
var mood = ""
|
var mood = ""
|
||||||
if mood == "" {
|
if mood == "" {
|
||||||
mood = g.pickone([]string { "sad", "happy", "surprised" })
|
mood = g.pickOne([]string{"sad", "happy", "surprised"})
|
||||||
}
|
}
|
||||||
var mouth string
|
var mouth string
|
||||||
if mood == "sad" {
|
if mood == "sad" {
|
||||||
@ -314,12 +316,12 @@ func femaleAvatar (seed uint64) string {
|
|||||||
"<path d='M9 11v2h2v-2H9z' fill='${mouthColor}'/>"
|
"<path d='M9 11v2h2v-2H9z' fill='${mouthColor}'/>"
|
||||||
}
|
}
|
||||||
|
|
||||||
var s = strings.Join([]string {
|
var s = strings.Join([]string{
|
||||||
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='isolation:isolate' viewBox='0 0 20 20' version='1.1' shape-rendering='crispEdges'>",
|
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='isolation:isolate' viewBox='0 0 20 20' version='1.1' shape-rendering='crispEdges'>",
|
||||||
// Head
|
// Head
|
||||||
"<path d='M3 20v-3h1v-1h4v-2H6v-1H5v-1H4v-1H3V9H2V7h1V4h1V3h1V2h10v1h1v1h1v3h1v2h-1v2h-1v1h-1v1h-1v1h-2v2h4v1h1v3H3z' fill='${skinColor}'/><path d='M14 14v-1h1v-1h1v-1h1V9h1V7h-1V4h-1V3h-1V2H5v1H4v1H3v3H2v2h1v2h1v1h1v1h1v1h8z' fill='#FFF' fill-opacity='.1'/>",
|
"<path d='M3 20v-3h1v-1h4v-2H6v-1H5v-1H4v-1H3V9H2V7h1V4h1V3h1V2h10v1h1v1h1v3h1v2h-1v2h-1v1h-1v1h-1v1h-2v2h4v1h1v3H3z' fill='${skinColor}'/><path d='M14 14v-1h1v-1h1v-1h1V9h1V7h-1V4h-1V3h-1V2H5v1H4v1H3v3H2v2h1v2h1v1h1v1h1v1h8z' fill='#FFF' fill-opacity='.1'/>",
|
||||||
// Eyes
|
// Eyes
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M5 9V7h3v2H5zm7-2h3v2h-3V7z' fill='#FFF'/><path d='M7 8v1h1V8H7zm7 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
"<path d='M5 9V7h3v2H5zm7-2h3v2h-3V7z' fill='#FFF'/><path d='M7 8v1h1V8H7zm7 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
||||||
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M6 8h1v1H6V8zm7 1V8h1v1h-1z' fill='${eyesColor}'/>",
|
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M6 8h1v1H6V8zm7 1V8h1v1h-1z' fill='${eyesColor}'/>",
|
||||||
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M7 8h1v1H7V8zm5 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill='#FFF'/><path d='M7 8h1v1H7V8zm5 0h1v1h-1V8z' fill='${eyesColor}'/>",
|
||||||
@ -335,7 +337,7 @@ func femaleAvatar (seed uint64) string {
|
|||||||
"<path d='M6 7h1v2H5V8h1V7zm7 0h1v2h-2V8h1V7z' fill='#FFF'/><path d='M7 7v1H6v1h2V7H7zm7 0v1h-1v1h2V7h-1z' fill='${eyesColor}'/><path d='M7 7v1h1V7H7zM6 8v1h1V8H6zm8-1v1h1V7h-1zm-1 1v1h1V8h-1z' fill='#FFF' fill-opacity='.5'/>",
|
"<path d='M6 7h1v2H5V8h1V7zm7 0h1v2h-2V8h1V7z' fill='#FFF'/><path d='M7 7v1H6v1h2V7H7zm7 0v1h-1v1h2V7h-1z' fill='${eyesColor}'/><path d='M7 7v1h1V7H7zM6 8v1h1V8H6zm8-1v1h1V7h-1zm-1 1v1h1V8h-1z' fill='#FFF' fill-opacity='.5'/>",
|
||||||
}),
|
}),
|
||||||
// Eyebrows
|
// Eyebrows
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M7 5v1H5v1H4V6h1V5h2zm7 0v1h-2v1h-1V6h1V5h2z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M7 5v1H5v1H4V6h1V5h2zm7 0v1h-2v1h-1V6h1V5h2z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
"<path d='M8 4v1H7v1H5V5h2V4h1zm4 0h1v1h2v1h-2V5h-1V4z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M8 4v1H7v1H5V5h2V4h1zm4 0h1v1h2v1h-2V5h-1V4z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
"<path d='M6 5h3v2H8V6H6V5zm5 0h3v1h-2v1h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M6 5h3v2H8V6H6V5zm5 0h3v1h-2v1h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
@ -351,8 +353,8 @@ func femaleAvatar (seed uint64) string {
|
|||||||
"<path d='M4 7V6h1V5h1v1H5v1H4zm10-2h1v1h1v1h-1V6h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
"<path d='M4 7V6h1V5h1v1H5v1H4zm10-2h1v1h1v1h-1V6h-1V5z' fill-rule='evenodd' fill='${eyebrowsColor}'/>",
|
||||||
}),
|
}),
|
||||||
// Accessories (15% chance)
|
// Accessories (15% chance)
|
||||||
g.pick_a_or_b(0.15,
|
g.pickAorB(0.15,
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M2 9v1h1V9H2zm15 0v1h1V9h-1z' fill-rule='evenodd' fill='${accessoriesColor}'/>",
|
"<path d='M2 9v1h1V9H2zm15 0v1h1V9h-1z' fill-rule='evenodd' fill='${accessoriesColor}'/>",
|
||||||
"<path d='M2 9v2h1V9H2zm15 0h1v2h-1V9z' fill-rule='evenodd' fill='${accessoriesColor}'/>",
|
"<path d='M2 9v2h1V9H2zm15 0h1v2h-1V9z' fill-rule='evenodd' fill='${accessoriesColor}'/>",
|
||||||
"<path d='M2 9v2h1V9H2zm15 0h1v2h-1V9z' fill='${accessoriesColor}'/><path d='M2 9v1h1V9H2zm15 0h1v1h-1V9z' fill='#FFF' fill-opacity='.4'/>",
|
"<path d='M2 9v2h1V9H2zm15 0h1v2h-1V9z' fill='${accessoriesColor}'/><path d='M2 9v1h1V9H2zm15 0h1v1h-1V9z' fill='#FFF' fill-opacity='.4'/>",
|
||||||
@ -362,8 +364,8 @@ func femaleAvatar (seed uint64) string {
|
|||||||
// Mouth
|
// Mouth
|
||||||
mouth,
|
mouth,
|
||||||
// Glasses (25% chance)
|
// Glasses (25% chance)
|
||||||
g.pick_a_or_b(0.25,
|
g.pickAorB(0.25,
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M3 8V7h1V6h2v1h1V6h2v1h2V6h2v1h1V6h2v1h1v1h-1v1h-1v1h-1v1h-1v-1h-1V9h-1V8H9v1H8v1H7v1H6v-1H5V9H4V8H3z' fill='${glassesColor}'/><path d='M3 7v1h1V7h1V6H4v1H3zm5-1v1h1v1h2V7h1V6h-1v1H9V6H8zm7 0v1h1v1h1V7h-1V6h-1z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M3 8V7h1V6h2v1h1V6h2v1h2V6h2v1h1V6h2v1h1v1h-1v1h-1v1h-1v1h-1v-1h-1V9h-1V8H9v1H8v1H7v1H6v-1H5V9H4V8H3z' fill='${glassesColor}'/><path d='M3 7v1h1V7h1V6H4v1H3zm5-1v1h1v1h2V7h1V6h-1v1H9V6H8zm7 0v1h1v1h1V7h-1V6h-1z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
||||||
"<path d='M5 7h3v3H5V7zm7 0h3v3h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M12 10V7h3v3h-3zm-1-4v1H9V6H4v1H3v1h1v3h5V8h2v3h5V8h1V7h-1V6h-5zm-6 4V7h3v3H5z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M5 7h3v3H5V7zm7 0h3v3h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M12 10V7h3v3h-3zm-1-4v1H9V6H4v1H3v1h1v3h5V8h2v3h5V8h1V7h-1V6h-5zm-6 4V7h3v3H5z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
||||||
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M5 7v2h3V7H5zM4 6v1H3v1h1v1h1v1h3V9h1V8h2v1h1v1h3V9h1V8h1V7h-1V6h-5v1H9V6H4zm8 1v2h3V7h-3z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M5 7h3v2H5V7zm7 0h3v2h-3V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M7 7h1v1H7V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/><path d='M5 7v2h3V7H5zM4 6v1H3v1h1v1h1v1h3V9h1V8h2v1h1v1h3V9h1V8h1V7h-1V6h-5v1H9V6H4zm8 1v2h3V7h-3z' fill-rule='evenodd' fill='${glassesColor}'/><path d='M3 7h1v1H3V7zm6 0h2v1H9V7zm7 0h1v1h-1V7z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
||||||
@ -374,7 +376,7 @@ func femaleAvatar (seed uint64) string {
|
|||||||
}),
|
}),
|
||||||
""),
|
""),
|
||||||
// Clothes
|
// Clothes
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/>",
|
"<path d='M3 20v-3h1v-1h12v1h1v3H3z' fill='${clothesColor}'/>",
|
||||||
"<path d='M4 16v4h4v-1H7v-1H6v-1H5v-1H4zm12 0v4h-4v-1h1v-1h1v-1h1v-1h1z' fill-rule='evenodd' fill='${clothesColor}'/>",
|
"<path d='M4 16v4h4v-1H7v-1H6v-1H5v-1H4zm12 0v4h-4v-1h1v-1h1v-1h1v-1h1z' fill-rule='evenodd' fill='${clothesColor}'/>",
|
||||||
"<path d='M5 16h1v2h1v1h1v1H5v-4zm9 0h1v4h-3v-1h1v-1h1v-2z' fill-rule='evenodd' fill='${clothesColor}'/>",
|
"<path d='M5 16h1v2h1v1h1v1H5v-4zm9 0h1v4h-3v-1h1v-1h1v-2z' fill-rule='evenodd' fill='${clothesColor}'/>",
|
||||||
@ -390,7 +392,7 @@ func femaleAvatar (seed uint64) string {
|
|||||||
"<path d='M3 20v-3h1v-1h5v1h2v-1h5v1h1v3H3z' fill='${clothesColor}'/><path d='M3 17h14v1H3v-1zm0 2v1h14v-1H3z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
"<path d='M3 20v-3h1v-1h5v1h2v-1h5v1h1v3H3z' fill='${clothesColor}'/><path d='M3 17h14v1H3v-1zm0 2v1h14v-1H3z' fill-rule='evenodd' fill='#FFF' fill-opacity='.2'/>",
|
||||||
}),
|
}),
|
||||||
// Hair
|
// Hair
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M2 9v6h2v-4H3V9H2zm0-2h2V4h12v3h2V3h-1V2H3v1H2v4zm15 2h1v6h-2v-4h1V9z' fill-rule='evenodd' fill='${hairColor}'/>",
|
"<path d='M2 9v6h2v-4H3V9H2zm0-2h2V4h12v3h2V3h-1V2H3v1H2v4zm15 2h1v6h-2v-4h1V9z' fill-rule='evenodd' fill='${hairColor}'/>",
|
||||||
"<path d='M4 12h1v1H3V4h1V3h1V2h10v1h1v1h1v9h-2v-1h1V5H4v7z' fill='${hairColor}'/>",
|
"<path d='M4 12h1v1H3V4h1V3h1V2h10v1h1v1h1v9h-2v-1h1V5H4v7z' fill='${hairColor}'/>",
|
||||||
"<path d='M2 17h2v-1h4v-2H6v-1H5v-1H4V4h1V3h1v1h1V3h1v1h1V3h6v1h1v8h-1v1h-1v1h-2v2h4v1h2V3h-1V2h-1V1H4v1H3v1H2v14z' fill='${hairColor}'/>",
|
"<path d='M2 17h2v-1h4v-2H6v-1H5v-1H4V4h1V3h1v1h1V3h1v1h1V3h6v1h1v8h-1v1h-1v1h-2v2h4v1h2V3h-1V2h-1V1H4v1H3v1H2v14z' fill='${hairColor}'/>",
|
||||||
@ -406,8 +408,8 @@ func femaleAvatar (seed uint64) string {
|
|||||||
"<path d='M2 9v3h1v1H2v2H1v1h1v-1h1v-1h1v-1h1v-1H4v-1H3V9H2zm16 0v3h-1v1h1v2h1v1h-1v-1h-1v-1h-1v-1h-1v-1h1v-1h1V9h1zm-1-2h1V3h-1V2h-1V1H4v1H3v1H2v4h1V6h1V5h2V4h9v1h1v1h1v1z' fill-rule='evenodd' fill='${hairColor}'/>",
|
"<path d='M2 9v3h1v1H2v2H1v1h1v-1h1v-1h1v-1h1v-1H4v-1H3V9H2zm16 0v3h-1v1h1v2h1v1h-1v-1h-1v-1h-1v-1h-1v-1h1v-1h1V9h1zm-1-2h1V3h-1V2h-1V1H4v1H3v1H2v4h1V6h1V5h2V4h9v1h1v1h1v1z' fill-rule='evenodd' fill='${hairColor}'/>",
|
||||||
}),
|
}),
|
||||||
// Hat (5% chance)
|
// Hat (5% chance)
|
||||||
g.pick_a_or_b(0.05,
|
g.pickAorB(0.05,
|
||||||
g.pickone([]string {
|
g.pickOne([]string{
|
||||||
"<path d='M4 0v2H2v2h16V2h-2V0H4z' fill='${hatColor}'/>",
|
"<path d='M4 0v2H2v2h16V2h-2V0H4z' fill='${hatColor}'/>",
|
||||||
"<path d='M4 3H2v1h16V3h-2V0H4v3z' fill='${hatColor}'/>",
|
"<path d='M4 3H2v1h16V3h-2V0H4v3z' fill='${hatColor}'/>",
|
||||||
"<path d='M2 2v2h16V2h-1V1h-1V0H4v1H3v1H2z' fill='${hatColor}'/>",
|
"<path d='M2 2v2h16V2h-1V1h-1V0H4v1H3v1H2z' fill='${hatColor}'/>",
|
||||||
@ -438,4 +440,3 @@ func femaleAvatar (seed uint64) string {
|
|||||||
}
|
}
|
||||||
return strings.NewReplacer(m...).Replace(s)
|
return strings.NewReplacer(m...).Replace(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user