mirror of
https://github.com/jointakahe/takahe.git
synced 2024-12-27 15:40:29 +00:00
3 lines
558 B
JavaScript
3 lines
558 B
JavaScript
function identicon(e,t=50,_=50){let c=e.split("").reduce((e,t)=>16777619*((e^t.charCodeAt(0))>>>0),2166136261);return[...Array(e?25:0)].reduce((e,t,_)=>c%(16-_%15)<4?e+`<rect x="${_>14?7-~~(_/5):~~(_/5)}" y="${_%5}" width="1" height="1"/>`:e,`<svg viewBox="-1.5 -1.5 8 8" xmlns="http://www.w3.org/2000/svg" fill="hsl(${c/16777619%18*20} ${t}% ${_}%)">`)+"</svg>"}
|
|
function generate_avatar(e){element.src=URL.createObjectURL(new Blob([identicon(e)],{type:"image/svg+xml;charset=utf8"}))}
|
|
function isAtTopOfPage(){return document.documentElement.scrollTop<30}
|