Multiavatar & vue-color-avatar
前者使用简单一点提供的有api,后者更类似一个项目
主要使用Multiavatar去实现随机生成头像的功能
https://github.com/multiavatar/Multiavatar/blob/main/multiavatar.js
使用很简单,把js下载保存到项目中,然后在html文件引入,即可全局使用
在utils中封装个方法,统一使用
// 渲染头像
export function getMultiavatarSvg(avatarId) {
if(`${avatarId}` && window.multiavatar){
return window.multiavatar && window.multiavatar(`${avatarId}`)
};
}
import {getMultiavatarSvg} from '@/utils
简单实用
直接给他传字符串,既可以生成svg的头像
当想生成多个随机头像时,我们只需要随机一个字符串数组,然后循环调用方法既可以生成多个头像
修改头像
换一组
取消
确定
import EditAvatarDialog from './EditAvatarDialog'
const isShowEditDialog = ref(false)
const editHandle = () => {
isShowEditDialog.value = true
}
const avatar = computed(() => {
const {profile} = store.state.user.loginData || {};
if(profile?.avatar){
return getMultiavatarSvg(profile?.avatar)
}
return ''
});
import Avatar from '@/views/Avatar/index.vue';
需用生成什么头像可以直接通过avatar属性进行相应的设置,也可以给Avatar这个组件去设置宽高,我封装的代码只是给了一个默认的宽高属性
// Multiavatar v1.0
// URL: https://multiavatar.com
// GitHub: https://github.com/multiavatar/Multiavatar
// Copyright: Gie Katon (2020-2021) (https://giekaton.com)
function multiavatar (string, sansEnv, ver) {
string += '';
var themes = {
// Robo
"00": {
"A": {
"env": ["#ff2f2b"],
"clo": ["#fff", "#000"],
"head": ["#fff"],
"mouth": ["#fff", "#000", "#000"],
"eyes": ["#000", "none", "#00FFFF"],
"top": ["#fff", "#fff"]
},
"B": {
"env": ["#ff1ec1"],
"clo": ["#000", "#fff" ],
"head": ["#ffc1c1"],
"mouth": ["#fff", "#000", "#000"],
"eyes": ["#FF2D00", "#fff", "none"],
"top": ["#a21d00", "#fff"]
},
"C": {
"env": ["#0079b1"],
"clo": ["#0e00b1", "#d1fffe"],
"head": ["#f5aa77"],
"mouth": ["#fff", "#000", "#000"],
"eyes": ["#0c00de", "#fff", "none"],
"top": ["#acfffd", "#acfffd"]
},
},
// Girl
"01": {
"A": {
"env": ["#a50000"],
"clo": ["#f06", "#8e0039"],
"head": ["#85492C"],
"mouth": ["#000"],
"eyes": ["#000", "#ff9809"],
"top": ["#ff9809", "#ff9809", "none", "none"]
},
"B": {
"env": ["#40E83B"],
"clo": ["#00650b", "#62ce5a"],
"head": ["#f7c1a6"],
"mouth": ["#6e1c1c"],
"eyes": ["#000", "#ff833b"],
"top": ["#67FFCC", "none", "none", "#ecff3b"]
},
"C": {
"env": ["#ff2c2c"],
"clo": ["#fff", "#000"],
"head": ["#ffce8b"],
"mouth": ["#000"],
"eyes": ["#000", "#0072ff"],
"top": ["#ff9809", "none", "#ffc809", "none"]
}
},
// Blonde
"02": {
"A": {
"env": ["#ff7520"],
"clo": ["#d12823"],
"head": ["#fee3c5"],
"mouth": ["#d12823"],
"eyes": ["#000", "none"],
"top": ["#000", "none", "none", "#FFCC00", "red"]
},
"B": {
"env": ["#ff9700"],
"clo": ["#000"],
"head": ["#d2ad6d"],
"mouth": ["#000"],
"eyes": ["#000", "#00ffdc"],
"top": ["#fdff00", "#fdff00", "none", "none", "none"]
},
"C": {
"env": ["#26a7ff"],
"clo": ["#d85cd7"],
"head": ["#542e02"],
"mouth": ["#f70014"],
"eyes": ["#000", "magenta"],
// "eyes": ["#000", "#ff0000"],
"top": ["#FFCC00", "#FFCC00", "#FFCC00", "#ff0000", "yellow"]
}
},
// Evilnormie
"03": {
"A": {
"env": ["#6FC30E"],
"clo": ["#b4e1fa", "#5b5d6e", "#515262", "#a0d2f0", "#a0d2f0"],
// "clo": ["#1f9ee4", "#262c5f", "#262c5f", "#a0d2f0", "#a0d2f0"],
"head": ["#fae3b9"],
"mouth": ["#fff", "#000"],
"eyes": ["#000"],
"top": ["#8eff45", "#8eff45", "none", "none"]
},
"B": {
"env": ["#00a58c"],
"clo": ["#000", "none", "none", "none", "none"],
"head": ["#FAD2B9"],
"mouth": ["#fff", "#000"],
"eyes": ["#000"],
"top": ["#FFC600", "none", "#FFC600", "none"]
},
"C": {
"env": ["#ff501f"],
"clo": ["#000", "#ff0000", "#ff0000", "#7d7d7d", "#7d7d7d"],
"head": ["#fff3dc"],
"mouth": ["#d2001b", "none"],
"eyes": ["#000"],
"top": ["#D2001B", "none", "none", "#D2001B"]
}
},
// Country
"04": {
"A": {
"env": ["#fc0"],
"clo": ["#901e0e", "#ffbe1e", "#ffbe1e", "#c55f54"],
"head": ["#f8d9ad"],
"mouth": ["#000", "none", "#000", "none"],
"eyes": ["#000"],
// "top": ["#48362D", "#AF892E", "#674C43", "#282828"]
"top": ["#583D00", "#AF892E", "#462D00", "#a0a0a0"]
},
"B": {
"env": ["#386465"],
"clo": ["#fff", "#333", "#333", "#333"],
"head": ["#FFD79D"],
"mouth": ["#000", "#000", "#000", "#000"],
"eyes": ["#000"],
"top": ["#27363C", "#5DCAD4", "#314652", "#333"]
// "top": ["#95E8CF", "#12353D", "#09A4AF", "#333"]
},
"C": {
"env": ["#DFFF00"],
"clo": ["#304267", "#aab0b1", "#aab0b1", "#aab0b1"],
"head": ["#e6b876"],
"mouth": ["#50230a", "#50230a", "#50230a", "#50230a"],
"eyes": ["#000"],
"top": ["#333", "#afafaf", "#222", "#6d3a1d"]
}
},
// Johnyold
"05": {
"A": {
// "env": ["#c7b810"],
"env": ["#a09300"],
"clo": ["#c7d4e2", "#435363", "#435363", "#141720", "#141720", "#e7ecf2", "#e7ecf2"],
"head": ["#f5d4a6"],
"mouth": ["#000", "#cf9f76"],
"eyes": ["#000", "#000", "#000", "#000", "#000", "#000", "#fff", "#fff", "#fff", "#fff", "#000", "#000"],
"top": ["none", "#fdff00"]
},
"B": {
"env": ["#b3003e"],
"clo": ["#000", "#435363", "#435363", "#000", "none", "#e7ecf2", "#e7ecf2"],
"head": ["#f5d4a6"],
"mouth": ["#000", "#af9f94"],
"eyes": ["#9ff3ff;opacity:0.96", "#000", "#9ff3ff;opacity:0.96", "#000", "#2f508a", "#000", "#000", "#000", "none", "none", "none", "none"],
"top": ["#ff9a00", "#ff9a00"]
},
"C": {
"env": ["#884f00"],
"clo": ["#ff0000", "#fff", "#fff", "#141720", "#141720", "#e7ecf2", "#e7ecf2"],
"head": ["#c57b14"],
"mouth": ["#000", "#cf9f76"],
"eyes": ["none", "#000", "none", "#000", "#5a0000", "#000", "#000", "#000", "none", "none", "none", "none"],
"top": ["#efefef", "none"]
}
},
// Asian
"06": {
"A": {
"env": ["#8acf00"],
"clo": ["#ee2829", "#ff0"],
"head": ["#ffce73"],
"mouth": ["#fff", "#000"],
"eyes": ["#000"],
"top": ["#000","#000","none", "#000", "#ff4e4e", "#000"]
},
"B": {
"env": ["#00d2a3"],
// "env": ["#007359"],
"clo": ["#0D0046", "#ffce73"],
"head": ["#ffce73"],
"mouth": ["#000", "none"],
"eyes": ["#000"],
"top": ["#000","#000","#000", "none", "#ffb358", "#000", "none", "none"]
// "top": ["#00898c", "#fff"]
},
"C": {
// "env": ["#C13D5C"],
"env": ["#ff184e"],
"clo": ["#000", "none"],
"head": ["#ffce73"],
"mouth": ["#ff0000", "none"],
"eyes": ["#000"],
"top": ["none","none","none", "none", "none", "#ffc107", "none", "none"]
}
},
// Punk
"07": {
"A": {
"env": ["#00deae"],
// "clo": ["#cc8562", "#f2efea", "#cc8562"],
"clo": ["#ff0000"],
"head": ["#ffce94"],
"mouth": ["#f73b6c", "#000"],
"eyes": ["#e91e63", "#000", "#e91e63", "#000", "#000", "#000"],
"top": ["#dd104f", "#dd104f", "#f73b6c", "#dd104f"]
},
"B": {
"env": ["#181284"],
"clo": ["#491f49", "#ff9809", "#491f49"],
"head": ["#f6ba97"],
"mouth": ["#ff9809", "#000"],
"eyes": ["#c4ffe4", "#000", "#c4ffe4", "#000", "#000", "#000"],
"top": [ "none", "none", "#d6f740", "#516303"]
},
"C": {
"env": ["#bcf700"],
"clo": ["#ff14e4", "#000", "#14fffd"],
"head": ["#7b401e"],
"mouth": ["#666", "#000"],
"eyes": ["#00b5b4", "#000", "#00b5b4", "#000", "#000", "#000"],
"top": ["#14fffd", "#14fffd", "#14fffd", "#0d3a62"]
}
},
// Afrohair
"08": {
"A": {
"env": ["#0df"],
"clo": ["#571e57", "#ff0"],
"head": ["#f2c280"],
"eyes": ["#795548", "#000"],
"mouth": ["#ff0000"],
"top": ["#de3b00", "none"]
},
"B": {
"env": ["#B400C2"],
"clo": ["#0D204A", "#00ffdf"],
"head": ["#ca8628"],
"eyes": ["#cbbdaf", "#000"],
"mouth": ["#1a1a1a"],
"top": ["#000", "#000"]
},
"C": {
"env": ["#ffe926"],
"clo": ["#00d6af", "#000"],
"head": ["#8c5100"],
"eyes": ["none", "#000"],
"mouth": ["#7d0000"],
"top": ["#f7f7f7", "none"]
}
},
// Normie female
"09": {
"A": {
"env": ["#4aff0c"],
"clo": ["#101010", "#fff", "#fff"],
"head": ["#dbbc7f"],
"mouth": ["#000"],
"eyes": [ "#000", "none", "none"],
"top": ["#531148", "#531148", "#531148", "none"]
},
"B": {
"env": ["#FFC107"],
"clo": ["#033c58", "#fff", "#fff"],
"head": ["#dbc97f"],
"mouth": ["#000"],
"eyes": ["none", "#fff", "#000"],
"top": ["#FFEB3B", "#FFEB3B", "none", "#FFEB3B"]
// "top": ["#085258", "#085258", "none", "#085258"]
},
"C": {
"env": ["#FF9800"],
"clo": ["#b40000", "#fff", "#fff"],
"head": ["#E2AF6B"],
"mouth": ["#000"],
"eyes": ["none", "#fff", "#000"],
"top": ["#ec0000", "#ec0000", "none", "none"]
}
},
// Older
"10": {
"A": {
"env": ["#104c8c"],
"clo": ["#354B65", "#3D8EBB", "#89D0DA", "#00FFFD" ],
"head": ["#cc9a5c"],
"mouth": ["#222", "#fff"],
"eyes": ["#000", "#000"],
"top": ["#fff", "#fff", "none"]
},
"B": {
"env": ["#0DC15C"],
"clo": ["#212121", "#fff", "#212121", "#fff" ],
"head": ["#dca45f"],
"mouth": ["#111", "#633b1d"],
"eyes": ["#000", "#000"],
"top": ["none", "#792B74", "#792B74"]
},
"C": {
"env": ["#ffe500"],
"clo": ["#1e5e80", "#fff", "#1e5e80", "#fff"],
"head": ["#e8bc86"],
"mouth": ["#111", "none"],
"eyes": ["#000", "#000"],
// "eyes": ["#636363", "#ADADAD", "#301e19"],
"top": ["none", "none", "#633b1d"]
}
},
// Firehair
"11": {
"A": {
"env": ["#4a3f73"],
"clo": ["#e6e9ee", "#f1543f", "#ff7058", "#fff", "#fff"],
"head": ["#b27e5b"],
"mouth": ["#191919", "#191919"],
"eyes": ["#000", "#000", "#57FFFD"],
"top": ["#ffc", "#ffc", "#ffc"]
},
"B": {
"env": ["#00a08d"],
"clo": ["#FFBA32", "#484848", "#4e4e4e", "#fff", "#fff"],
"head": ["#ab5f2c"],
"mouth": ["#191919", "#191919"],
// "#61b7ff",
"eyes": ["#000", "#ff23fa;opacity:0.39", "#000"],
"top": ["#ff90f4", "#ff90f4", "#ff90f4"]
},
"C": {
"env": ["#22535d"],
"clo": ["#000", "#ff2500", "#ff2500", "#fff", "#fff"],
"head": ["#a76c44"],
"mouth": ["#191919", "#191919"],
"eyes": ["#000", "none", "#000"],
"top": ["none", "#00efff", "none"]
}
},
// Blond
"12": {
"A": {
"env": ["#2668DC"],
"clo": ["#2385c6", "#b8d0e0", "#b8d0e0"],
"head": ["#ad8a60"],
"mouth": ["#000", "#4d4d4d"],
"eyes": ["#7fb5a2", "#d1eddf", "#301e19"],
// "top": ["#ff6"]
// "top": ["#ff0"]
"top": ["#fff510", "#fff510"]
},
"B": {
"env": ["#643869"],
"clo": ["#D67D1B", "#b8d0e0", "#b8d0e0"],
"head": ["#CC985A", "none0000"],
"mouth": ["#000", "#ececec"],
"eyes": ["#1f2644", "#9b97ce", "#301e19"],
// "top": ["#c700c7"]
// "top": ["#c54560"]
// "top": ["#ff393e", "none"]
"top": ["#00eaff", "none"]
},
"C": {
"env": ["#F599FF"],
"clo": ["#2823C6", "#b8d0e0", "#b8d0e0"],
"head": ["#C7873A"],
"mouth": ["#000", "#4d4d4d"],
"eyes": ["#581b1b", "#FF8B8B", "#000"],
// "top": ["#5F1F1F"]
// "top": ["#fff00"]
"top": ["none", "#9c0092"]
}
},
// Ateam
"13": {
"A": {
"env": ["#d10084"],
"clo": ["#efedee", "#00a1e0", "#00a1e0", "#efedee", "#ffce1c"],
"head": ["#b35f49"],
"mouth": ["#3a484a", "#000"],
"eyes": ["#000"],
"top": ["#000", "none", "#000", "none"]
},
"B": {
"env": ["#E6C117"],
"clo": ["#efedee", "#ec0033", "#ec0033", "#efedee", "#f2ff05"],
"head": ["#ffc016"],
"mouth": ["#4a3737", "#000"],
"eyes": ["#000"],
"top": ["#ffe900", "#ffe900", "none", "#ffe900"]
},
"C": {
"env": ["#1d8c00"],
// "env": ["#C6FE3C"],
// "env": ["#cace10"],
"clo": ["#e000cb", "#fff", "#fff", "#e000cb", "#ffce1c"],
"head": ["#b96438"],
"mouth": ["#000", "#000"],
"eyes": ["#000"],
// "top": ["#eff4b0"]
// "top": ["#e0e0e0"]
// "top": ["#d7ffff"] // ice
// "top": ["#f0ffff"] // ice
"top": ["#53ffff", "#53ffff", "none", "none"]
}
},
// Rasta
"14": {
"A": {
"env": ["#fc0065"],
"clo": ["#708913", "#fdea14", "#708913", "#fdea14", "#708913"],
"head": ["#DEA561"],
"mouth": ["#444", "#000"],
"eyes": ["#000"],
"top": ["#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f" ]
},
"B": {
"env": ["#81f72e"],
"clo": ["#ff0000", "#ffc107", "#ff0000", "#ffc107", "#ff0000"],
"head": ["#ef9831"],
// "mouth": ["#a2a2a2", "#000"],
"mouth": ["#6b0000", "#000"],
"eyes": ["#000"],
"top": ["#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "none", "none", "none", "none"]
},
"C": {
"env": ["#00D872"],
"clo": ["#590D00", "#FD1336", "#590D00", "#FD1336", "#590D00"],
"head": ["#c36c00"],
"mouth": ["#56442b", "#000"],
"eyes": ["#000"],
"top": ["#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "none", "none", "none", "none", "none", "none", "none", "none"]
}
},
// Meta
"15": {
"A": {
// "env": ["#ccc"],
"env": ["#111"],
"clo": ["#000", "#00FFFF"],
"head": ["#755227"],
"mouth": ["#fff", "#000"],
"eyes": ["black", "#008;opacity:0.67", "aqua"],
// "top": ["#004a57"] // dark blue
"top": ["#fff", "#fff", "#fff", "#fff", "#fff"]
},
"B": {
"env": ["#00D0D4"],
// "env": ["#30afab"],
// "env": ["#E8E8E8"],
"clo": ["#000", "#fff"],
"head": ["#755227"],
"mouth": ["#fff", "#000"],
// "eyes": ["black", "black", "#ff0303"],
"eyes": ["black", "#1df7ff;opacity:0.64", "#fcff2c"],
// "top": ["#fffbaf"] // bright yellow
"top": ["#fff539", "none", "#fff539", "none", "#fff539"]
},
"C": {
"env": ["#DC75FF"],
"clo": ["#000", "#FFBDEC"],
"head": ["#997549"],
"mouth": ["#fff", "#000"],
"eyes": ["black", "black", "aqua"],
// "top": ["#474747"]
// "top": ["#ff64e6"]
"top": ["#00fffd", "none", "none", "none", "none"]
}
}
}
var sP = [];
var svgStart = '';
// Optimization
var env = ' ';
var head = ' ';
var str = 'stroke-linecap:round;stroke-linejoin:round;stroke-width:';
// The below code is automatically injected by running /svg/_build.php script
// PHP_inject_start
// Robo
sP['00'] = [];
sP['00']['env'] = env;
sP['00']['clo'] = ' ';
sP['00']['head'] = head;
sP['00']['mouth'] = ' ';
sP['00']['eyes'] = ' ';
sP['00']['top'] = ' ';
// Girl
sP['01'] = [];
sP['01']['env'] = env;
sP['01']['clo'] = ' ';
sP['01']['head'] = head;
sP['01']['mouth'] = ' ';
sP['01']['eyes'] = ' ';
sP['01']['top'] = ' ';
// Blonde
sP['02'] = [];
sP['02']['env'] = env;
sP['02']['clo'] = ' ';
sP['02']['head'] = head;
sP['02']['mouth'] = ' ';
sP['02']['eyes'] = ' ';
sP['02']['top'] = ' ';
// Guy
sP['03'] = [];
sP['03']['env'] = env;
sP['03']['clo'] = ' ';
sP['03']['head'] = head;
sP['03']['mouth'] = ' ';
sP['03']['eyes'] = ' ';
sP['03']['top'] = ' ';
// Country
sP['04'] = [];
sP['04']['env'] = env;
sP['04']['clo'] = ' ';
sP['04']['head'] = head;
sP['04']['mouth'] = ' ';
sP['04']['eyes'] = ' ';
sP['04']['top'] = ' ';
// Geeknot
sP['05'] = [];
sP['05']['env'] = env;
sP['05']['clo'] = ' ';
sP['05']['head'] = head;
sP['05']['mouth'] = ' ';
sP['05']['eyes'] = ' ';
sP['05']['top'] = ' ';
// Asian
sP['06'] = [];
sP['06']['env'] = env;
sP['06']['clo'] = ' ';
sP['06']['head'] = head;
sP['06']['mouth'] = ' ';
sP['06']['eyes'] = ' ';
sP['06']['top'] = ' ';
// Punk
sP['07'] = [];
sP['07']['env'] = env;
sP['07']['clo'] = ' ';
sP['07']['head'] = head;
sP['07']['mouth'] = ' ';
sP['07']['eyes'] = ' ';
sP['07']['top'] = ' ';
// Afrohair
sP['08'] = [];
sP['08']['env'] = env;
sP['08']['clo'] = ' ';
sP['08']['head'] = head;
sP['08']['mouth'] = ' ';
sP['08']['eyes'] = ' ';
sP['08']['top'] = ' ';
// Normie Female
sP['09'] = [];
sP['09']['env'] = env;
sP['09']['clo'] = ' ';
sP['09']['head'] = head;
sP['09']['mouth'] = ' ';
sP['09']['eyes'] = ' ';
sP['09']['top'] = ' ';
// Older
sP['10'] = [];
sP['10']['env'] = env;
sP['10']['clo'] = ' ';
sP['10']['head'] = head;
sP['10']['mouth'] = ' ';
sP['10']['eyes'] = ' ';
sP['10']['top'] = ' ';
// Firehair
sP['11'] = [];
sP['11']['env'] = env;
sP['11']['clo'] = ' ';
sP['11']['head'] = head;
sP['11']['mouth'] = ' ';
sP['11']['eyes'] = ' ';
sP['11']['top'] = ' ';
// Blond
sP['12'] = [];
sP['12']['env'] = env;
sP['12']['clo'] = ' ';
sP['12']['head'] = head;
sP['12']['mouth'] = ' ';
sP['12']['eyes'] = ' ';
sP['12']['top'] = ' ';
// Ateam
sP['13'] = [];
sP['13']['env'] = env;
sP['13']['clo'] = ' ';
sP['13']['head'] = head;
sP['13']['mouth'] = ' ';
sP['13']['eyes'] = ' ';
sP['13']['top'] = ' ';
// Rasta
sP['14'] = [];
sP['14']['env'] = env;
sP['14']['clo'] = ' ';
sP['14']['head'] = head;
sP['14']['mouth'] = ' ';
sP['14']['eyes'] = ' ';
sP['14']['top'] = ' ';
// Meta
sP['15'] = [];
sP['15']['env'] = env;
sP['15']['clo'] = ' ';
sP['15']['head'] = head;
sP['15']['mouth'] = ' ';
sP['15']['eyes'] = ' ';
sP['15']['top'] = ' ';
// PHP_inject_end
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS=CryptoJS||function(h,s){var f={},t=f.lib={},g=function(){},j=t.Base={extend:function(a){g.prototype=this;var c=new g;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
q=t.WordArray=j.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||u).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=j.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b,
2),16)<<24-4*(b%8);return new q.init(d,c/2)}},k=v.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},l=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}},
x=t.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=l.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var m=0;mk;){var l;a:{l=u;for(var x=h.sqrt(l),w=2;w<=x;w++)if(!(l%w)){l=!1;break a}l=!0}l&&(8>k&&(j[k]=v(h.pow(u,0.5))),q[k]=v(h.pow(u,1/3)),k++);u++}var a=[],f=f.SHA256=g.extend({_doReset:function(){this._hash=new t.init(j.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],m=b[2],h=b[3],p=b[4],j=b[5],k=b[6],l=b[7],n=0;64>n;n++){if(16>n)a[n]=
c[d+n]|0;else{var r=a[n-15],g=a[n-2];a[n]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+a[n-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+a[n-16]}r=l+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+(p&j^~p&k)+q[n]+a[n];g=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&m^f&m);l=k;k=j;j=p;p=h+r|0;h=m;m=f;f=e;e=r+g|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+m|0;b[3]=b[3]+h|0;b[4]=b[4]+p|0;b[5]=b[5]+j|0;b[6]=b[6]+k|0;b[7]=b[7]+l|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;
d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=g.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=g._createHelper(f);s.HmacSHA256=g._createHmacHelper(f)})(Math);
var hash = '';
if (string.length == 0) return hash;
var sha256Hash = CryptoJS.SHA256(string);
var sha256Numbers = sha256Hash.toString().replace(/\D/g,'');
hash = sha256Numbers.substring(0, 12);
// parts
var p = [];
// Get parts (range 0-47)
p['env'] = hash[0] + '' + hash[1];
p['env'] = Math.round((47/100)*p['env']) + '';
// Freeze a single part
// e.g. '0' = 01A; '16' = 01B; '32' = 01C; '1' = 02A; '17' = 02B;
// p['env'] = '16';
p['clo'] = hash[2] + '' + hash[3];
p['clo'] = Math.round((47/100)*p['clo']) + '';
// p['clo'] = '16';
p['head'] = hash[4] + '' + hash[5];
p['head'] = Math.round((47/100)*p['head']) + '';
// p['head'] = '01';
p['mouth'] = hash[6] + '' + hash[7];
p['mouth'] = Math.round((47/100)*p['mouth']) + '';
// p['mouth'] = '16';
p['eyes'] = hash[8] + '' + hash[9];
p['eyes'] = Math.round((47/100)*p['eyes']) + '';
// p['eyes'] = '16';
p['top'] = hash[10] + '' + hash[11];
p['top'] = Math.round((47/100)*p['top']) + '';
// p['top'] = '25';
// Get parts (range 0-15) + define themes
for (var part in p) {
var nr = p[part];
if (nr > 31) {
nr = nr - 32 + '';
if (nr.length == 1) nr = '0' + nr;
p[part] = nr + 'C';
}
else if (nr > 15) {
nr = nr - 16 + '';
if (nr.length == 1) nr = '0' + nr;
p[part] = nr + 'B';
} else {
if ((nr+'').length == 1) p[part] = '0' + nr + 'A';
else p[part] = nr + 'A';
}
}
// Get the SVG code for each part
var final = [];
for (var part in p) {
var partV = p[part].substring(0,2);
var theme = p[part].substring(2,3);
// console.log(part, partV, theme);
if (typeof(ver) != 'undefined') {
partV = ver.part;
theme = ver.theme;
}
// Freeze a single base version
// partV = '00'; theme = 'A';
final[part] = getFinal(part, partV, theme);
// console.log(final[part]);
}
function getFinal(part, partV, theme) {
// console.log(part, partV, theme)
var colors = themes[partV][theme][part];
var svgString = sP[partV][part];
// console.log(colors, svgString);
var regex = /#(.*?);/g;
var result = svgString.match(regex);
var resultFinal = svgString;
if (result != null) {
for (var i = 0; i < result.length; i++) {
// console.log('replace', result[i], colors[i])
resultFinal = resultFinal.replace(result[i], colors[i]+';');
}
}
// console.log(resultFinal)
return resultFinal;
}
// Without 'env'
if (sansEnv) {
final['env'] = '';
}
return(svgStart + final['env'] + final['head'] + final['clo'] + final['top']+ final['eyes'] + final['mouth'] + svgEnd);
}