lively-mascot 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/CHANGELOG.zh-CN.md +37 -0
- package/LICENSE +21 -0
- package/README.md +357 -0
- package/README.zh-CN.md +357 -0
- package/dist/lively-mascot.cjs +1 -0
- package/dist/lively-mascot.min.css +3115 -0
- package/dist/lively-mascot.min.js +8 -0
- package/dist/lively-mascot.mjs +10 -0
- package/package.json +72 -0
- package/src/characters/cat.css +331 -0
- package/src/characters/cat.js +130 -0
- package/src/characters/ghost.css +77 -0
- package/src/characters/ghost.js +68 -0
- package/src/characters/jelly.css +54 -0
- package/src/characters/jelly.js +55 -0
- package/src/characters/robot.css +83 -0
- package/src/characters/robot.js +82 -0
- package/src/characters/sprout.css +69 -0
- package/src/characters/sprout.js +87 -0
- package/src/core/emotions.js +206 -0
- package/src/core/rig.js +282 -0
- package/src/lively-mascot.css +2501 -0
- package/src/lively-mascot.js +330 -0
- package/types/index.d.ts +66 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
(()=>{var ce=(g,t)=>()=>{try{return t||g((t={exports:{}}).exports,t),t.exports}catch(d){throw t=0,d}};var de=ce((I,j)=>{window.LivelyEmotions={"00":{id:"00",name:"Sleep",group:"lifecycle",desc:"\u6DF1\u5EA6\u7761\u7720",blink:!1,gaze:!1,bodyFilter:"brightness(0.55) saturate(0.6)",leafAnim:"lively-leaf-sleep 6s ease-in-out infinite",footAnim:"lively-foot-rest 4s ease-in-out infinite"},"01":{id:"01",name:"Wake",group:"lifecycle",desc:"\u521A\u7761\u9192",bodyAnim:"lively-wake 1.2s ease-out",leafAnim:"lively-leaf-wake 0.8s ease-out",footAnim:"lively-foot-wake 0.6s ease-out"},"02":{id:"02",name:"Idle",group:"lifecycle",desc:"\u5F85\u673A"},"03":{id:"03",name:"Breathe",group:"lifecycle",desc:"\u5E73\u7A33\u547C\u5438",bodyAnim:"lively-deep-breathe 4s ease-in-out infinite",leafAnim:"lively-leaf-breathe 4s ease-in-out infinite",footAnim:"lively-foot-rest 4s ease-in-out infinite"},"04":{id:"04",name:"Ready",group:"lifecycle",desc:"\u968F\u65F6\u5F85\u547D",bodyAnim:"lively-ready 2s ease-in-out infinite",leafAnim:"lively-leaf-ready 1.5s ease-in-out infinite",footAnim:"lively-foot-ready 1.8s ease-in-out infinite"},"05":{id:"05",name:"Pause",group:"lifecycle",desc:"\u6682\u505C\u4E2D",bodyFilter:"saturate(0.4) brightness(0.85)",leafAnim:"lively-leaf-pause 6s ease-in-out infinite",footAnim:"lively-foot-rest 4s ease-in-out infinite"},"06":{id:"06",name:"Refresh",group:"lifecycle",desc:"\u6B63\u5728\u5237\u65B0",bodyAnim:"lively-refresh 0.8s ease-in-out infinite",leafAnim:"lively-leaf-refresh 0.6s ease-in-out infinite"},"07":{id:"07",name:"LowBattery",group:"lifecycle",desc:"\u7535\u91CF\u4E0D\u8DB3",bodyFilter:"saturate(0.3) brightness(0.7)",bodyAnim:"lively-lowbatt 2.5s ease-in-out infinite",leafAnim:"lively-leaf-droop 3s ease-in-out infinite",footAnim:"lively-foot-rest 5s ease-in-out infinite"},"08":{id:"08",name:"Offline",group:"lifecycle",desc:"\u5DF2\u79BB\u7EBF",blink:!1,gaze:!1,bodyFilter:"grayscale(1) brightness(0.5)",leafAnim:"lively-leaf-droop 8s ease-in-out infinite"},"09":{id:"09",name:"Boot",group:"lifecycle",desc:"\u542F\u52A8\u4E2D",bodyAnim:"lively-boot 0.5s ease-in-out 3",leafAnim:"lively-leaf-boot 0.4s ease-out 3",footAnim:"lively-foot-boot 0.3s ease-out 3"},10:{id:"10",name:"Happy",group:"reaction",desc:"\u5F00\u5FC3",gaze:!1,bodyAnim:"lively-happy-bounce 0.6s ease-in-out 2",leafAnim:"lively-leaf-happy 0.4s ease-in-out 4",footAnim:"lively-foot-happy 0.35s ease-in-out 4"},11:{id:"11",name:"Excited",group:"reaction",desc:"\u5174\u594B",gaze:!1,bodyAnim:"lively-excited 0.5s ease-in-out 3",leafAnim:"lively-leaf-excited 0.3s ease-in-out 5",footAnim:"lively-foot-excited 0.25s ease-in-out 6"},12:{id:"12",name:"Sad",group:"reaction",desc:"\u96BE\u8FC7",gaze:!1,bodyAnim:"lively-sad 3s ease-in-out infinite",bodyFilter:"brightness(0.85) saturate(0.7)",leafAnim:"lively-leaf-droop 2s ease-in-out infinite",footAnim:"lively-foot-rest 4s ease-in-out infinite"},13:{id:"13",name:"Angry",group:"reaction",desc:"\u751F\u6C14",gaze:!1,bodyAnim:"lively-angry 0.15s linear infinite",bodyFilter:"hue-rotate(340deg) saturate(1.5) brightness(0.95)",leafAnim:"lively-leaf-angry 0.12s linear infinite",footAnim:"lively-foot-stomp 0.18s ease-in-out infinite"},14:{id:"14",name:"Surprised",group:"reaction",desc:"\u60CA\u8BB6",gaze:!1,bodyAnim:"lively-surprise 0.5s ease-out",leafAnim:"lively-leaf-wake 0.5s ease-out"},15:{id:"15",name:"Shy",group:"reaction",desc:"\u5BB3\u7F9E",gaze:!1,bodyAnim:"lively-confused 2s ease-in-out infinite",leafAnim:"lively-leaf-shy 2s ease-in-out infinite"},16:{id:"16",name:"Love",group:"reaction",desc:"\u5FC3\u52A8",gaze:!1,bodyAnim:"lively-love-pulse 0.8s ease-in-out infinite",leafAnim:"lively-leaf-happy 0.6s ease-in-out infinite"},17:{id:"17",name:"Confused",group:"reaction",desc:"\u56F0\u60D1",bodyAnim:"lively-confused 2s ease-in-out infinite",leafAnim:"lively-leaf-confused 1.5s ease-in-out infinite"},18:{id:"18",name:"Cool",group:"reaction",desc:"\u800D\u9177",bodyFilter:"contrast(1.15) brightness(1.05)",leafAnim:"lively-leaf-ready 2s ease-in-out infinite"},19:{id:"19",name:"Smug",group:"reaction",desc:"\u5F97\u610F",bodyAnim:"lively-smug 2s ease-in-out infinite",leafAnim:"lively-leaf-ready 1.8s ease-in-out infinite"},20:{id:"20",name:"Thinking",group:"work",desc:"\u601D\u8003\u4E2D",blink:!1,bodyAnim:"lively-thinking 2.5s ease-in-out infinite",leafAnim:"lively-leaf-thinking 2s ease-in-out infinite"},21:{id:"21",name:"Listening",group:"work",desc:"\u503E\u542C\u4E2D",bodyAnim:"lively-listening 2s ease-in-out infinite",leafAnim:"lively-leaf-listen 1.8s ease-in-out infinite"},22:{id:"22",name:"Talking",group:"work",desc:"\u8BF4\u8BDD\u4E2D",bodyAnim:"lively-talking 0.5s ease-in-out infinite",leafAnim:"lively-leaf-talking 0.8s ease-in-out infinite"},23:{id:"23",name:"Searching",group:"work",desc:"\u641C\u7D22\u4E2D",bodyAnim:"lively-searching 1.5s ease-in-out infinite",leafAnim:"lively-leaf-searching 1.2s ease-in-out infinite",footAnim:"lively-foot-pace 0.8s ease-in-out infinite"},24:{id:"24",name:"Reading",group:"work",desc:"\u9605\u8BFB\u4E2D",bodyAnim:"lively-reading 3s ease-in-out infinite",leafAnim:"lively-leaf-reading 2.5s ease-in-out infinite"},25:{id:"25",name:"Writing",group:"work",desc:"\u5199\u4F5C\u4E2D",bodyAnim:"lively-writing 1.8s ease-in-out infinite",leafAnim:"lively-leaf-writing 1.5s ease-in-out infinite",footAnim:"lively-foot-writing 1.2s ease-in-out infinite"},26:{id:"26",name:"Coding",group:"work",desc:"\u7F16\u7A0B\u4E2D",blink:!1,bodyAnim:"lively-coding 2.5s ease-in-out infinite",leafAnim:"lively-leaf-coding 2s ease-in-out infinite"},27:{id:"27",name:"Designing",group:"work",desc:"\u8BBE\u8BA1\u4E2D",bodyAnim:"lively-designing 3s ease-in-out infinite",leafAnim:"lively-leaf-designing 2.5s ease-in-out infinite"},28:{id:"28",name:"Loading",group:"work",desc:"\u52A0\u8F7D\u4E2D",gaze:!1,bodyAnim:"lively-loading-bounce 0.9s ease-in-out infinite",footAnim:"lively-foot-rest 3s ease-in-out infinite"},29:{id:"29",name:"Processing",group:"work",desc:"\u5904\u7406\u4E2D",bodyAnim:"lively-processing 1.5s ease-in-out infinite",leafAnim:"lively-leaf-thinking 1.2s ease-in-out infinite"},30:{id:"30",name:"Success",group:"work",desc:"\u4EFB\u52A1\u5B8C\u6210",gaze:!1,bodyAnim:"lively-success 0.7s ease-out",leafAnim:"lively-leaf-happy 0.5s ease-out 2"},31:{id:"31",name:"Error",group:"work",desc:"\u53D1\u751F\u9519\u8BEF",gaze:!1,bodyFilter:"brightness(0.8) saturate(0.6)",bodyAnim:"lively-error 0.25s linear 4",leafAnim:"lively-leaf-error 0.2s linear 4"},32:{id:"32",name:"Grateful",group:"reaction",desc:"\u611F\u8C22",gaze:!1,bodyAnim:"lively-love-pulse 1.2s ease-in-out infinite",leafAnim:"lively-leaf-happy 1s ease-in-out infinite"},33:{id:"33",name:"Retrying",group:"work",desc:"\u91CD\u8BD5\u4E2D",bodyAnim:"lively-searching 1.2s ease-in-out infinite",leafAnim:"lively-leaf-confused 1s ease-in-out infinite",footAnim:"lively-foot-pace 0.6s ease-in-out infinite"},34:{id:"34",name:"Cancelled",group:"work",desc:"\u5DF2\u53D6\u6D88",bodyFilter:"saturate(0.5) brightness(0.8)",leafAnim:"lively-leaf-droop 3s ease-in-out infinite",footAnim:"lively-foot-rest 3s ease-in-out infinite"},35:{id:"35",name:"Crying",group:"reaction",desc:"\u54ED\u6CE3",gaze:!1,bodyFilter:"brightness(0.9) saturate(0.8)",bodyAnim:"lively-sad 2s ease-in-out infinite",leafAnim:"lively-leaf-droop 1.5s ease-in-out infinite",footAnim:"lively-foot-rest 3s ease-in-out infinite"},36:{id:"36",name:"Bored",group:"reaction",desc:"\u65E0\u804A",bodyAnim:"lively-bored 4s ease-in-out infinite",leafAnim:"lively-leaf-droop 5s ease-in-out infinite",footAnim:"lively-foot-rest 4s ease-in-out infinite"},37:{id:"37",name:"Nervous",group:"reaction",desc:"\u7D27\u5F20",bodyAnim:"lively-nervous 0.8s ease-in-out infinite",leafAnim:"lively-leaf-nervous 0.6s ease-in-out infinite",footAnim:"lively-foot-nervous 0.3s ease-in-out infinite"},38:{id:"38",name:"Eureka",group:"reaction",desc:"\u7075\u5149\u4E00\u73B0",gaze:!1,bodyAnim:"lively-eureka 0.6s ease-out",leafAnim:"lively-leaf-eureka 0.4s ease-out 2",footAnim:"lively-foot-happy 0.3s ease-out 3"},39:{id:"39",name:"Waiting",group:"work",desc:"\u7B49\u5F85\u4E2D",bodyAnim:"lively-waiting 2s ease-in-out infinite",leafAnim:"lively-leaf-waiting 1.5s ease-in-out infinite",footAnim:"lively-foot-tap 0.5s ease-in-out infinite"}};var se={lifecycle:{name:"\u751F\u547D\u5468\u671F",order:0},reaction:{name:"\u60C5\u7EEA\u53CD\u5E94",order:1},work:{name:"\u5DE5\u4F5C\u72B6\u6001",order:2}};typeof j=="object"&&j.exports&&(j.exports={emotions:LivelyEmotions,groups:se});typeof globalThis<"u"&&(globalThis.LivelyEmotions=LivelyEmotions,globalThis.LivelyEmotionGroups=se);var ne=function(g,t,d){return g<t?t:g>d?d:g};function q(g,t,d,b){d=d||{},b=b||{};var r=d.animated!==!1,l=d.followCursor!==!1,s=d.gazeRadiusX||200,e=d.gazeRadiusY||160,a=d.hopInterval===void 0?[6,13]:d.hopInterval,i=[],f=[],A=null,S=!1,B=!1,E=r&&l,w="02",x=null,v=null,c=!0,m=null,n=null,h={},p=null,u={registerPupil:function(o,y){for(var C=0;C<i.length;C++)if(i[C].el===o){i[C].spec=y;return}i.push({el:o,spec:y||{maxX:8,maxY:6}})},registerEye:function(o){f.indexOf(o)===-1&&f.push(o)},registerFace:function(o){A=o},registerBody:function(o){x=o},registerLeaf:function(o,y){v=o,c=!(y&&y.useLeafAnim===!1)},registerFeet:function(o){m=o},registerGazeWrap:function(o){n=o},registerFaceAccessory:function(o,y){!o||!y||(h[String(o)]=y,y.classList.add("lively-face-accessory"),p===null&&(p=String(o)),y.classList.toggle("is-active",p===String(o)))},setFaceAccessory:function(o){var y=o==null?null:String(o);p=y;for(var C in h)Object.prototype.hasOwnProperty.call(h,C)&&h[C].classList.toggle("is-active",C===y)},setEmotionState:function(o){w=String(o),L(w),ie()}};function T(o){S!==o&&(S=o,g.classList.toggle("is-happy",o))}function k(o){B!==o&&(B=o,g.classList.toggle("is-hopping",o))}function M(o){return LivelyEmotions[String(o)]}function P(){if(x&&(x.style.animation="",x.style.filter=""),t.style.animation="",v&&c&&(v.style.animation=""),m){m.style.removeProperty("--lively-state-filter");var o=m.querySelector(".lively__foot--l"),y=m.querySelector(".lively__foot--r");o&&(o.style.animation=""),y&&(y.style.animation="")}}function L(o){var y=M(o);if(!y){P();return}if(!r){x&&(x.style.filter=y.bodyFilter||""),m&&m.style.setProperty("--lively-state-filter",y.bodyFilter||"brightness(1)");return}if(x&&(x.style.animation=y.bodyAnim||"",x.style.filter=y.bodyFilter||""),v&&c&&(v.style.animation=y.leafAnim||""),m){m.style.setProperty("--lively-state-filter",y.bodyFilter||"brightness(1)");var C=m.querySelector(".lively__foot--l"),F=m.querySelector(".lively__foot--r");C&&(C.style.animation=y.footAnim||""),F&&(F.style.animation=y.footAnim||"")}o==="06"||o==="28"?(x&&(x.style.animation=""),t.style.animation=y.bodyAnim||""):t.style.animation=""}var _=0,O=g.getBoundingClientRect(),W=performance.now(),X=0,Y=0,z=0,N=0;function J(){var o=M(w);return o&&o.gaze===!1||w!=="02"?!1:E}function U(o){if(J()){var y=performance.now();y-W>250&&(O=g.getBoundingClientRect(),W=y);var C=O.left+O.width/2,F=O.top+O.height/2;X=ne((o.clientX-C)/s,-1,1),Y=ne((o.clientY-F)/e,-1,1)}}function K(){J()||(X=0,Y=0),z+=(X-z)*.2,N+=(Y-N)*.2;for(var o=0;o<i.length;o++){var y=i[o];y.el.setAttribute("transform","translate("+(z*y.spec.maxX).toFixed(2)+" "+(N*y.spec.maxY).toFixed(2)+")")}A&&A.setAttribute("transform","rotate("+(z*3).toFixed(2)+" 50 52)");var C=n||t;if(g.classList.contains("lively-mascot--3d")){var F=performance.now()/720+Number(w||0)*.67,R=w==="02"?0:Math.sin(F)*1.2,Q=w==="02"?0:Math.cos(F*.82)*1.7,le=3.2-N*7.2+R,ae=-3.2+z*9.4+Q,re=1+Math.abs(ae)*.0027,fe=1+Math.abs(le)*.0022;g.style.setProperty("--lively-gloss-x",(25+z*15).toFixed(1)+"%"),g.style.setProperty("--lively-gloss-y",(18+N*12).toFixed(1)+"%"),C.style.transform="translate3d("+(z*2.2).toFixed(1)+"px, "+(N*1.4).toFixed(1)+"px, 3px) scale3d("+re.toFixed(3)+", "+fe.toFixed(3)+", 1) rotateZ("+(z*1.8).toFixed(2)+"deg) rotateX("+le.toFixed(2)+"deg) rotateY("+ae.toFixed(2)+"deg)"}else C.style.transform="rotate("+(z*5).toFixed(2)+"deg) translate3d("+(z*4).toFixed(1)+"px, "+(N*2.5).toFixed(1)+"px, 0)";_=requestAnimationFrame(K)}var D=0,G=0;function V(){var o=M(w);if(o&&o.blink===!1){D=window.setTimeout(V,300);return}var y=o&&o.blink==="fast"?800+Math.random()*1200:2200+Math.random()*2600;D=window.setTimeout(function(){for(var C=0;C<f.length;C++)f[C].classList.add("is-blinking");G=window.setTimeout(function(){for(var F=0;F<f.length;F++)f[F].classList.remove("is-blinking");Math.random()<.18?G=window.setTimeout(function(){for(var R=0;R<f.length;R++)f[R].classList.add("is-blinking");G=window.setTimeout(function(){for(var Q=0;Q<f.length;Q++)f[Q].classList.remove("is-blinking");V()},90)},160):V()},110)},y)}var Z=0,H=0;function $(){var o=M(w);return r&&!!a&&!!(o&&o.hop)}function oe(){clearTimeout(Z),clearTimeout(H),Z=0,H=0,k(!1)}function ee(){$()&&(Z=window.setTimeout(function(){$()&&(k(!0),H=window.setTimeout(function(){k(!1),ee()},900))},a[0]*1e3+Math.random()*(a[1]-a[0])*1e3))}function ie(){oe(),ee()}function te(){b.onClick&&b.onClick(),w==="02"&&(T(!0),setTimeout(function(){T(!1)},950))}return E&&(_=requestAnimationFrame(K),window.addEventListener("pointermove",U,{passive:!0})),r&&(V(),ie(),g.addEventListener("pointerdown",te)),{api:u,click:te,setFollowCursor:function(o){E=o},destroy:function(){cancelAnimationFrame(_),window.removeEventListener("pointermove",U),clearTimeout(D),clearTimeout(G),clearTimeout(Z),clearTimeout(H)}}}typeof j=="object"&&j.exports&&(j.exports={createRig:q});typeof globalThis<"u"&&(globalThis.createRig=q);/**
|
|
2
|
+
* lively-mascot · core SDK (v0.2.0)
|
|
3
|
+
*
|
|
4
|
+
* Requires: src/core/emotions.js, src/core/rig.js (loaded before this script)
|
|
5
|
+
* Character files (src/characters/*.js) register themselves after this script.
|
|
6
|
+
*
|
|
7
|
+
* @license MIT
|
|
8
|
+
*/(function(g,t){var d=typeof self<"u"?self:this;d.LivelyMascot=(function(b,r){"use strict";function l(v,c,m){var n=document.createElement(v);if(c){for(var h in c)if(Object.prototype.hasOwnProperty.call(c,h)){var p=c[h];if(p==null||p==="")continue;h==="class"?n.className=String(p):h==="text"?n.textContent=String(p):n.setAttribute(h,String(p))}}if(m)for(var u=0;u<m.length;u++)n.appendChild(m[u]);return n}var s="http://www.w3.org/2000/svg";function e(v,c,m){var n=document.createElementNS(s,v);if(c){for(var h in c)if(Object.prototype.hasOwnProperty.call(c,h)){var p=c[h];if(p==null||p==="")continue;n.setAttribute(h,String(p))}}if(m)for(var u=0;u<m.length;u++)n.appendChild(m[u]);return n}function a(v,c,m){var n=document.createElement(v);if(c){for(var h in c)if(Object.prototype.hasOwnProperty.call(c,h)){var p=c[h];if(p==null||p==="")continue;h==="class"?n.className=String(p):h==="text"?n.textContent=String(p):n.setAttribute(h,String(p))}}if(m)for(var u=0;u<m.length;u++)n.appendChild(m[u]);return n}function i(v){var c="lively-eye-clip-"+Math.random().toString(36).slice(2,9);function m(k,M){var P=e("g",{transform:"translate("+k+" "+M+")"}),L=e("g",{class:"lively-face__eye"});v.registerEye(L),L.appendChild(e("ellipse",{rx:10,ry:11.5}));var _=e("g",{"clip-path":"url(#"+c+")"}),O=e("g");return v.registerPupil(O,{maxX:8,maxY:6}),O.appendChild(e("circle",{class:"lively-face__pupil",r:6.2})),O.appendChild(e("circle",{class:"lively-face__shine",cx:2.2,cy:-2.4,r:2.1})),_.appendChild(O),L.appendChild(_),L.appendChild(e("path",{class:"lively-face__happy",d:"M-6.5 1.5 Q0 -6 6.5 1.5"})),P.appendChild(L),P}var n=e("g",{class:"lively-face"});v.registerFace(n),n.appendChild(e("ellipse",{class:"lively-face__blush",cx:20,cy:57,rx:7,ry:4})),n.appendChild(e("ellipse",{class:"lively-face__blush",cx:80,cy:57,rx:7,ry:4})),n.appendChild(m(34,43)),n.appendChild(m(66,43)),n.appendChild(e("path",{class:"lively-face__mouth",d:"M42 63 Q50 70 58 63"})),n.appendChild(e("path",{class:"lively-face__happy-mouth",d:"M40 61 Q50 74 60 61 Q50 66 40 61 Z"})),n.appendChild(e("path",{class:"lively-face__sad-mouth",d:"M43 67 Q50 62 57 67"})),n.appendChild(e("ellipse",{class:"lively-face__open-mouth",cx:50,cy:65,rx:5,ry:6})),n.appendChild(e("line",{class:"lively-face__flat-mouth",x1:43,y1:65,x2:57,y2:65})),n.appendChild(e("path",{class:"lively-face__bored-mouth",d:"M42.5 65.2 C47.5 65.9 53 65.7 57.5 64.2"})),n.appendChild(e("line",{class:"lively-face__sleep-eye lively-face__sleep-eye--l",x1:27,y1:43,x2:41,y2:43})),n.appendChild(e("line",{class:"lively-face__sleep-eye lively-face__sleep-eye--r",x1:59,y1:43,x2:73,y2:43})),n.appendChild(e("line",{class:"lively-face__angry-brow lively-face__angry-brow--l",x1:25,y1:32,x2:38,y2:35})),n.appendChild(e("line",{class:"lively-face__angry-brow lively-face__angry-brow--r",x1:75,y1:32,x2:62,y2:35})),n.appendChild(e("g",{class:"lively-face__x-eye lively-face__x-eye--l",transform:"translate(34,43)"},[e("line",{x1:-6,y1:-7,x2:6,y2:7}),e("line",{x1:6,y1:-7,x2:-6,y2:7})])),n.appendChild(e("g",{class:"lively-face__x-eye lively-face__x-eye--r",transform:"translate(66,43)"},[e("line",{x1:-6,y1:-7,x2:6,y2:7}),e("line",{x1:6,y1:-7,x2:-6,y2:7})])),n.appendChild(e("path",{class:"lively-face__heart-eye lively-face__heart-eye--l",transform:"translate(34,42)",d:"M0 3 C0 0, -5 -4, -7 -1 C-9 2, 0 9, 0 9 C0 9, 9 2, 7 -1 C5 -4, 0 0, 0 3Z"})),n.appendChild(e("path",{class:"lively-face__heart-eye lively-face__heart-eye--r",transform:"translate(66,42)",d:"M0 3 C0 0, -5 -4, -7 -1 C-9 2, 0 9, 0 9 C0 9, 9 2, 7 -1 C5 -4, 0 0, 0 3Z"})),n.appendChild(e("path",{class:"lively-face__cry-eye lively-face__cry-eye--l",transform:"translate(34,43)",d:"M-6 2 Q0 -4 6 2"})),n.appendChild(e("path",{class:"lively-face__cry-eye lively-face__cry-eye--r",transform:"translate(66,43)",d:"M-6 2 Q0 -4 6 2"})),n.appendChild(e("g",{class:"lively-face__tear lively-face__tear--l",transform:"translate(40,52)"},[e("ellipse",{cx:0,cy:0,rx:2.5,ry:3.5,fill:"#6ec7ff",opacity:"0.8"}),e("ellipse",{cx:0,cy:8,rx:1.8,ry:2.5,fill:"#6ec7ff",opacity:"0.5"})])),n.appendChild(e("g",{class:"lively-face__tear lively-face__tear--r",transform:"translate(60,52)"},[e("ellipse",{cx:0,cy:0,rx:2.5,ry:3.5,fill:"#6ec7ff",opacity:"0.8"}),e("ellipse",{cx:0,cy:8,rx:1.8,ry:2.5,fill:"#6ec7ff",opacity:"0.5"})])),n.appendChild(e("g",{class:"lively-face__sweat",transform:"translate(82,30)"},[e("path",{d:"M0 0 C-3 5, -3 10, 0 12 C3 10, 3 5, 0 0Z",fill:"#6ec7ff",opacity:"0.7"})])),n.appendChild(e("g",{class:"lively-face__star-eye lively-face__star-eye--l",transform:"translate(34,43)"},[e("polygon",{points:"0,-8 2,-3 7,-3 3,1 5,7 0,3 -5,7 -3,1 -7,-3 -2,-3",fill:"#ffe066"})])),n.appendChild(e("g",{class:"lively-face__star-eye lively-face__star-eye--r",transform:"translate(66,43)"},[e("polygon",{points:"0,-8 2,-3 7,-3 3,1 5,7 0,3 -5,7 -3,1 -7,-3 -2,-3",fill:"#ffe066"})])),n.appendChild(e("g",{class:"lively-face__sparkle lively-face__sparkle--1",transform:"translate(15,20)"},[e("line",{x1:0,y1:-4,x2:0,y2:4,stroke:"#ffe066","stroke-width":"1.5"}),e("line",{x1:-4,y1:0,x2:4,y2:0,stroke:"#ffe066","stroke-width":"1.5"})])),n.appendChild(e("g",{class:"lively-face__sparkle lively-face__sparkle--2",transform:"translate(85,18)"},[e("line",{x1:0,y1:-3,x2:0,y2:3,stroke:"#ffe066","stroke-width":"1.2"}),e("line",{x1:-3,y1:0,x2:3,y2:0,stroke:"#ffe066","stroke-width":"1.2"})])),n.appendChild(e("g",{class:"lively-face__waiting-dots",transform:"translate(42,68)"},[e("circle",{cx:0,cy:0,r:2,fill:"#888"}),e("circle",{cx:8,cy:0,r:2,fill:"#888"}),e("circle",{cx:16,cy:0,r:2,fill:"#888"})]));var h=e("svg",{viewBox:"0 0 100 100","aria-hidden":"true"}),p=e("defs"),u=e("clipPath",{id:c});u.appendChild(e("ellipse",{rx:10,ry:11.5})),p.appendChild(u),h.appendChild(p),h.appendChild(n);var T=a("div",{class:"lively-face-wrap"});return T.appendChild(h),{wrap:T,face:n}}var f={};function A(v,c,m,n){f[v]={id:v,name:m||v,viewBox:n||"0 0 100 100",render:c}}function S(v){return f[v]||f.sprout}function B(v){return String(v||"3d").toLowerCase()==="2d"?"2d":"3d"}function E(v){return v!==!1&&String(v).toLowerCase()!=="false"}function w(v,c){c=c||{};var m=c.type||"sprout",n=S(m),h=B(c.viewMode||c.mode),p=E(c.outlineVisible),u=l("div",{class:"lively-mascot lively-mascot--"+n.id+" lively-mascot--"+h+(p?"":" lively-mascot--outline-hidden")+(c.animated===!1?" lively-mascot--static":""),style:"width:"+(c.size||106)+"px;height:"+(c.size||106)+"px","aria-hidden":"true"}),T=l("div",{class:"lively-mascot__rig"}),k=l("div",{class:"lively-mascot__gaze"});T.appendChild(k);var M={body:c.color||"",outline:c.outline||"",accent:c.accent||""};function P(){u.style.setProperty("--lively-body",M.body||null),u.style.setProperty("--lively-outline",M.outline||null),u.style.setProperty("--lively-accent",M.accent||null)}P();var L=q(u,T,{followCursor:c.followCursor,hopInterval:c.hopInterval,animated:c.animated},{onClick:c.onClick});return n.render(L.api,k),L.api.registerGazeWrap(k),k.appendChild(l("div",{class:"lively__loading-overlay","aria-hidden":"true"})),u.appendChild(T),v.appendChild(u),{el:u,type:n.id,get viewMode(){return h},setViewMode:function(_){return h=B(_),u.classList.toggle("lively-mascot--2d",h==="2d"),u.classList.toggle("lively-mascot--3d",h==="3d"),h},get outlineVisible(){return p},setOutlineVisible:function(_){return p=E(_),u.classList.toggle("lively-mascot--outline-hidden",!p),p},setTheme:function(_){_=_||{},_.body&&(M.body=_.body),_.outline&&(M.outline=_.outline),_.accent&&(M.accent=_.accent),P()},setEmotion:function(_){u.className=u.className.replace(/is-emotion-\d+/g,"").trim(),u.classList.add("is-emotion-"+_),L.api.setEmotionState(String(_))},clearEmotion:function(){u.className=u.className.replace(/is-emotion-\d+/g,"").trim(),u.classList.add("is-emotion-02"),L.api.setEmotionState("02")},destroy:function(){L.destroy(),u.remove()}}}function x(v){if(v=v||"lively-mascot",!(typeof customElements>"u"||customElements.get(v))){var c=w,m=(function(){function n(){var h=this.constructor,p=Reflect.construct(HTMLElement,[],h);return p}return n.prototype=Object.create(HTMLElement.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),n.observedAttributes=["type","color","size","view-mode","mode","show-outline"],n.prototype.connectedCallback=function(){this._render()},n.prototype.disconnectedCallback=function(){this._inst&&this._inst.destroy(),this._inst=null,this.textContent=""},n.prototype.attributeChangedCallback=function(){this.isConnected&&this._render()},n.prototype._render=function(){this._inst&&this._inst.destroy(),this.textContent="",this._inst=c(this,{type:this.getAttribute("type"),color:this.getAttribute("color"),size:this.getAttribute("size")?Number(this.getAttribute("size")):void 0,viewMode:this.getAttribute("view-mode")||this.getAttribute("mode")||void 0,outlineVisible:this.getAttribute("show-outline")!=="false"})},n})();customElements.define(v,m)}}return{createMascot:w,registerCharacter:A,defineMascotElement:x,buildFaceSvg:i,characters:f,emotions:r,emotionGroups:b,version:"0.2.0"}})(g,t)})((typeof self<"u"?self:I).LivelyEmotionGroups||{},(typeof self<"u"?self:I).LivelyEmotions||{});(function(){"use strict";var g="http://www.w3.org/2000/svg";function t(r,l,s){var e=document.createElementNS(g,r);if(l)for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&e.setAttribute(a,String(l[a]));if(s)for(var i=0;i<s.length;i++)e.appendChild(s[i]);return e}function d(r,l,s){var e=document.createElement(r);if(l){for(var a in l)if(Object.prototype.hasOwnProperty.call(l,a)){var i=l[a];if(i==null||i==="")continue;a==="class"?e.className=String(i):a==="text"?e.textContent=String(i):e.setAttribute(a,String(i))}}if(s)for(var f=0;f<s.length;f++)e.appendChild(s[f]);return e}function b(r,l){var s=d("span",{class:"lively__leaf","aria-hidden":"true"});r.registerLeaf(s),s.appendChild(t("svg",{viewBox:"0 0 52 56"},[t("path",{class:"lively-sprout__stem",d:"M26 52 C26 42, 26 34, 26 27"}),t("path",{class:"lively-sprout__leaf",d:"M26 28 C22 15, 14 9, 6 12 C5 20, 12 29, 26 28 Z"}),t("path",{class:"lively-sprout__vein",d:"M23 26 C18 21, 12 16, 8 14"}),t("path",{class:"lively-sprout__shine",d:"M22 26 C16 16, 11 12, 7 14"}),t("path",{class:"lively-sprout__leaf",d:"M26 28 C30 15, 38 9, 46 12 C47 20, 40 29, 26 28 Z"}),t("path",{class:"lively-sprout__vein",d:"M29 26 C34 21, 40 16, 44 14"}),t("path",{class:"lively-sprout__shine",d:"M30 26 C36 16, 41 12, 45 14"})]));var e=d("div",{class:"lively-body"});r.registerBody(e);var a=LivelyMascot.buildFaceSvg(r);e.appendChild(s),e.appendChild(a.wrap),l.appendChild(e);var i=d("div",{class:"lively__feet"});r.registerFeet(i);var f=d("span",{class:"lively__foot lively__foot--l"});f.appendChild(t("svg",{viewBox:"0 0 22 16"},[t("ellipse",{class:"lively-foot__body",cx:11,cy:10,rx:10,ry:6}),t("ellipse",{class:"lively-foot__shine",cx:8,cy:7,rx:3,ry:1.8})]));var A=d("span",{class:"lively__foot lively__foot--r"});A.appendChild(t("svg",{viewBox:"0 0 22 16"},[t("ellipse",{class:"lively-foot__body",cx:11,cy:10,rx:10,ry:6}),t("ellipse",{class:"lively-foot__shine",cx:8,cy:7,rx:3,ry:1.8})])),i.appendChild(f),i.appendChild(A),l.appendChild(i)}typeof LivelyMascot<"u"?LivelyMascot.registerCharacter("sprout",b,"Sprout","0 0 100 100"):document.addEventListener("DOMContentLoaded",function(){typeof LivelyMascot<"u"&&LivelyMascot.registerCharacter("sprout",b,"Sprout","0 0 100 100")})})();(function(){"use strict";var g="http://www.w3.org/2000/svg";function t(r,l,s){var e=document.createElementNS(g,r);if(l)for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&e.setAttribute(a,String(l[a]));if(s)for(var i=0;i<s.length;i++)e.appendChild(s[i]);return e}function d(r,l,s){var e=document.createElement(r);if(l){for(var a in l)if(Object.prototype.hasOwnProperty.call(l,a)){var i=l[a];if(i==null||i==="")continue;a==="class"?e.className=String(i):a==="text"?e.textContent=String(i):e.setAttribute(a,String(i))}}if(s)for(var f=0;f<s.length;f++)e.appendChild(s[f]);return e}function b(r,l){var s=d("span",{class:"lively__ears","aria-hidden":"true"}),e=t("g",{class:"lively__ear-left"},[t("path",{class:"lively__ear",d:"M1 30 C2 17 5 6 10 1 Q11 0 13 3 C18 14 20 24 20 30 C13 32 6 32 1 30 Z"}),t("path",{class:"lively__ear--inner",d:"M6 28 C6 19 8 10 10 6 Q11 5 12 7 C15 15 16 23 16 28 C12 29 9 29 6 28 Z"})]),a=t("g",{class:"lively__ear-right"},[t("path",{class:"lively__ear",d:"M59 30 C58 17 55 6 50 1 Q49 0 47 3 C42 14 40 24 40 30 C47 32 54 32 59 30 Z"}),t("path",{class:"lively__ear--inner",d:"M54 28 C54 19 52 10 50 6 Q49 5 48 7 C45 15 44 23 44 28 C48 29 51 29 54 28 Z"})]);s.appendChild(t("svg",{viewBox:"0 0 60 32"},[e,a])),r.registerLeaf(s,{useLeafAnim:!1});var i=d("div",{class:"lively-body lively-body--cat"});r.registerBody(i);var f=d("span",{class:"lively__tail","aria-hidden":"true"});f.appendChild(t("svg",{viewBox:"0 0 52 58"},[t("g",{class:"lively-cat__tail-motion"},[t("path",{class:"lively-cat__tail-outline",d:"M-10 56 C-7 40, 0 25, 17 16 C28 10, 43 11, 46 20 C48 27, 42 32, 35 28"}),t("path",{class:"lively-cat__tail-path",d:"M-10 56 C-7 40, 0 25, 17 16 C28 10, 43 11, 46 20 C48 27, 42 32, 35 28"}),t("circle",{class:"lively-cat__tail-tip",cx:35,cy:28,r:3.2})])]));var A=LivelyMascot.buildFaceSvg(r),S=A.face;S.insertBefore(t("ellipse",{class:"lively-cat__muzzle",cx:38,cy:61,rx:10,ry:6}),S.firstChild),S.insertBefore(t("ellipse",{class:"lively-cat__muzzle",cx:62,cy:61,rx:10,ry:6}),S.firstChild),S.appendChild(t("path",{class:"lively-face__cat-nose-bridge",d:"M50 59 L50 63"})),S.appendChild(t("path",{class:"lively-face__cat-nose",d:"M46 57 Q50 55 54 57 L50 61 Z"}));var B=d("span",{class:"lively-cat__whiskers","aria-hidden":"true"});B.appendChild(t("svg",{viewBox:"0 0 100 100"},[t("path",{class:"lively-cat__whisker lively-cat__whisker--l1",d:"M34 57 C24 53 17 50 9 50"}),t("path",{class:"lively-cat__whisker lively-cat__whisker--l2",d:"M33 61 C22 60 15 60 7 62"}),t("path",{class:"lively-cat__whisker lively-cat__whisker--l3",d:"M34 65 C24 67 18 70 11 74"}),t("path",{class:"lively-cat__whisker lively-cat__whisker--r1",d:"M66 57 C76 53 83 50 91 50"}),t("path",{class:"lively-cat__whisker lively-cat__whisker--r2",d:"M67 61 C78 60 85 60 93 62"}),t("path",{class:"lively-cat__whisker lively-cat__whisker--r3",d:"M66 65 C76 67 82 70 89 74"})])),r.registerFaceAccessory("whiskers",B),r.setFaceAccessory("whiskers"),i.appendChild(s),i.appendChild(A.wrap),i.appendChild(B),l.appendChild(i),l.appendChild(f);var E=d("div",{class:"lively__feet"});r.registerFeet(E);var w=d("span",{class:"lively__foot lively__foot--l"});w.appendChild(t("svg",{viewBox:"0 0 22 16"},[t("ellipse",{class:"lively-foot__body",cx:11,cy:10,rx:10,ry:6}),t("ellipse",{class:"lively-foot__shine",cx:8,cy:7,rx:3,ry:1.8}),t("path",{class:"lively-cat__toe-lines",d:"M7 10 Q7 8 8 7 M11 11 Q11 9 12 8 M15 10 Q15 8 16 7"})]));var x=d("span",{class:"lively__foot lively__foot--r"});x.appendChild(t("svg",{viewBox:"0 0 22 16"},[t("ellipse",{class:"lively-foot__body",cx:11,cy:10,rx:10,ry:6}),t("ellipse",{class:"lively-foot__shine",cx:8,cy:7,rx:3,ry:1.8}),t("path",{class:"lively-cat__toe-lines",d:"M7 10 Q7 8 8 7 M11 11 Q11 9 12 8 M15 10 Q15 8 16 7"})])),E.appendChild(w),E.appendChild(x),l.appendChild(E)}typeof LivelyMascot<"u"?LivelyMascot.registerCharacter("cat",b,"Cat","0 0 100 100"):document.addEventListener("DOMContentLoaded",function(){typeof LivelyMascot<"u"&&LivelyMascot.registerCharacter("cat",b,"Cat","0 0 100 100")})})();(function(){"use strict";var g="http://www.w3.org/2000/svg";function t(r,l,s){var e=document.createElementNS(g,r);if(l)for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&e.setAttribute(a,String(l[a]));if(s)for(var i=0;i<s.length;i++)e.appendChild(s[i]);return e}function d(r,l,s){var e=document.createElement(r);if(l){for(var a in l)if(Object.prototype.hasOwnProperty.call(l,a)){var i=l[a];if(i==null||i==="")continue;a==="class"?e.className=String(i):a==="text"?e.textContent=String(i):e.setAttribute(a,String(i))}}if(s)for(var f=0;f<s.length;f++)e.appendChild(s[f]);return e}function b(r,l){var s=d("span",{class:"lively__antenna","aria-hidden":"true"});r.registerLeaf(s,{useLeafAnim:!1}),s.appendChild(t("svg",{viewBox:"0 0 40 36"},[t("line",{class:"lively-robot__antenna-stalk",x1:20,y1:34,x2:20,y2:8}),t("circle",{class:"lively-robot__antenna-ball",cx:20,cy:5,r:5})]));var e=d("div",{class:"lively-body lively-body--robot"});r.registerBody(e);var a=LivelyMascot.buildFaceSvg(r);e.appendChild(s),e.appendChild(a.wrap),l.appendChild(e);var i=d("div",{class:"lively__feet lively__feet--robot"});r.registerFeet(i);var f=d("span",{class:"lively__foot lively__foot--l"});f.appendChild(t("svg",{viewBox:"0 0 22 16"},[t("rect",{class:"lively-robot__foot",x:1,y:3,width:20,height:12,rx:3}),t("rect",{class:"lively-robot__foot-line",x:4,y:7,width:14,height:2,rx:1})]));var A=d("span",{class:"lively__foot lively__foot--r"});A.appendChild(t("svg",{viewBox:"0 0 22 16"},[t("rect",{class:"lively-robot__foot",x:1,y:3,width:20,height:12,rx:3}),t("rect",{class:"lively-robot__foot-line",x:4,y:7,width:14,height:2,rx:1})])),i.appendChild(f),i.appendChild(A),l.appendChild(i)}typeof LivelyMascot<"u"?LivelyMascot.registerCharacter("robot",b,"Robot","0 0 100 100"):document.addEventListener("DOMContentLoaded",function(){typeof LivelyMascot<"u"&&LivelyMascot.registerCharacter("robot",b,"Robot","0 0 100 100")})})();(function(){"use strict";var g="http://www.w3.org/2000/svg";function t(r,l,s){var e=document.createElementNS(g,r);if(l)for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&e.setAttribute(a,String(l[a]));if(s)for(var i=0;i<s.length;i++)e.appendChild(s[i]);return e}function d(r,l,s){var e=document.createElement(r);if(l){for(var a in l)if(Object.prototype.hasOwnProperty.call(l,a)){var i=l[a];if(i==null||i==="")continue;a==="class"?e.className=String(i):a==="text"?e.textContent=String(i):e.setAttribute(a,String(i))}}if(s)for(var f=0;f<s.length;f++)e.appendChild(s[f]);return e}function b(r,l){var s=d("div",{class:"lively-body lively-body--ghost"});r.registerBody(s);var e=LivelyMascot.buildFaceSvg(r);s.appendChild(e.wrap);var a=d("div",{class:"lively__ghost-hem"});a.appendChild(t("svg",{viewBox:"0 0 100 6",preserveAspectRatio:"none"},[t("path",{class:"lively-ghost__hem-stroke",d:"M0 0 C11.1 6 22.2 6 33.3 0 C44.4 6 55.6 6 66.7 0 C77.8 6 88.9 6 100 0"})])),s.appendChild(a),l.appendChild(s)}typeof LivelyMascot<"u"?LivelyMascot.registerCharacter("ghost",b,"Ghost","0 0 100 100"):document.addEventListener("DOMContentLoaded",function(){typeof LivelyMascot<"u"&&LivelyMascot.registerCharacter("ghost",b,"Ghost","0 0 100 100")})})();(function(){"use strict";var g="http://www.w3.org/2000/svg";function t(r,l,s){var e=document.createElementNS(g,r);if(l)for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&e.setAttribute(a,String(l[a]));if(s)for(var i=0;i<s.length;i++)e.appendChild(s[i]);return e}function d(r,l,s){var e=document.createElement(r);if(l){for(var a in l)if(Object.prototype.hasOwnProperty.call(l,a)){var i=l[a];if(i==null||i==="")continue;a==="class"?e.className=String(i):a==="text"?e.textContent=String(i):e.setAttribute(a,String(i))}}if(s)for(var f=0;f<s.length;f++)e.appendChild(s[f]);return e}function b(r,l){var s=d("div",{class:"lively-body lively-body--jelly"});r.registerBody(s);var e=LivelyMascot.buildFaceSvg(r);s.appendChild(e.wrap),l.appendChild(s)}typeof LivelyMascot<"u"?LivelyMascot.registerCharacter("jelly",b,"Jelly","0 0 100 100"):document.addEventListener("DOMContentLoaded",function(){typeof LivelyMascot<"u"&&LivelyMascot.registerCharacter("jelly",b,"Jelly","0 0 100 100")})})()});de();})();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import mascot from "./lively-mascot.cjs";
|
|
2
|
+
export const createMascot = mascot.createMascot;
|
|
3
|
+
export const registerCharacter = mascot.registerCharacter;
|
|
4
|
+
export const defineMascotElement = mascot.defineMascotElement;
|
|
5
|
+
export const buildFaceSvg = mascot.buildFaceSvg;
|
|
6
|
+
export const characters = mascot.characters;
|
|
7
|
+
export const emotions = mascot.emotions;
|
|
8
|
+
export const emotionGroups = mascot.emotionGroups;
|
|
9
|
+
export const version = mascot.version;
|
|
10
|
+
export default mascot;
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lively-mascot",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Universal Animated Mascot Engine: 40 Emotions · 5 Characters · Pure SVG · Zero Dependencies · Data-Driven · Drop-in.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/lively-mascot.cjs",
|
|
7
|
+
"module": "./dist/lively-mascot.mjs",
|
|
8
|
+
"browser": "./dist/lively-mascot.min.js",
|
|
9
|
+
"unpkg": "./dist/lively-mascot.min.js",
|
|
10
|
+
"jsdelivr": "./dist/lively-mascot.min.js",
|
|
11
|
+
"types": "./types/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"require": "./dist/lively-mascot.cjs",
|
|
16
|
+
"import": "./dist/lively-mascot.mjs",
|
|
17
|
+
"default": "./dist/lively-mascot.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./dist/lively-mascot.min.js": "./dist/lively-mascot.min.js",
|
|
20
|
+
"./dist/lively-mascot.min.css": "./dist/lively-mascot.min.css",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"mascot",
|
|
25
|
+
"animated",
|
|
26
|
+
"avatar",
|
|
27
|
+
"chatbot",
|
|
28
|
+
"desktop-pet",
|
|
29
|
+
"emotion-engine",
|
|
30
|
+
"web-component",
|
|
31
|
+
"no-build",
|
|
32
|
+
"svg-animation",
|
|
33
|
+
"multi-character",
|
|
34
|
+
"ghost",
|
|
35
|
+
"jelly",
|
|
36
|
+
"robot"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "node scripts/build-dist.mjs"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist/lively-mascot.min.js",
|
|
43
|
+
"dist/lively-mascot.min.css",
|
|
44
|
+
"dist/lively-mascot.cjs",
|
|
45
|
+
"dist/lively-mascot.mjs",
|
|
46
|
+
"types/index.d.ts",
|
|
47
|
+
"CHANGELOG.md",
|
|
48
|
+
"CHANGELOG.zh-CN.md",
|
|
49
|
+
"src/lively-mascot.js",
|
|
50
|
+
"src/lively-mascot.css",
|
|
51
|
+
"src/core/emotions.js",
|
|
52
|
+
"src/core/rig.js",
|
|
53
|
+
"src/characters/sprout.js",
|
|
54
|
+
"src/characters/sprout.css",
|
|
55
|
+
"src/characters/cat.js",
|
|
56
|
+
"src/characters/cat.css",
|
|
57
|
+
"src/characters/robot.js",
|
|
58
|
+
"src/characters/robot.css",
|
|
59
|
+
"src/characters/ghost.js",
|
|
60
|
+
"src/characters/ghost.css",
|
|
61
|
+
"src/characters/jelly.js",
|
|
62
|
+
"src/characters/jelly.css",
|
|
63
|
+
"README.zh-CN.md"
|
|
64
|
+
],
|
|
65
|
+
"repository": {
|
|
66
|
+
"type": "git",
|
|
67
|
+
"url": "https://github.com/jingluoguo/lively-mascot"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"esbuild": "^0.28.2"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/* ============================================================
|
|
2
|
+
* lively-mascot · Cat Character Styles
|
|
3
|
+
*
|
|
4
|
+
* An original charcoal cat with pointed ears, a curled tail, and floating whiskers.
|
|
5
|
+
* ============================================================ */
|
|
6
|
+
|
|
7
|
+
/* --- Body shape: a compact feline head with a slightly tapered jaw --- */
|
|
8
|
+
.lively-mascot--cat .lively-body {
|
|
9
|
+
border-radius: 48% 48% 43% 43% / 45% 45% 55% 55%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* A charcoal default gives the cat its own identity; inline themes still win. */
|
|
13
|
+
.lively-mascot--cat {
|
|
14
|
+
--lively-body: #3d4852;
|
|
15
|
+
--lively-outline: #131a20;
|
|
16
|
+
--lively-accent: #eeb3c1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* --- Ears: pointed cat ears on top (nested inside body so they
|
|
20
|
+
follow body bounce / squash / boot / wake animations) --- */
|
|
21
|
+
.lively__ears {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: -17cqw;
|
|
24
|
+
left: 50%;
|
|
25
|
+
width: 66cqw;
|
|
26
|
+
height: 29cqw;
|
|
27
|
+
margin-left: -33cqw;
|
|
28
|
+
z-index: 3;
|
|
29
|
+
transform-origin: 50% 92%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Each ear splays slightly outward for a more natural arc */
|
|
33
|
+
.lively__ear-left { transform-box: fill-box; transform-origin: 50% 100%; transform: rotate(-7deg); }
|
|
34
|
+
.lively__ear-right { transform-box: fill-box; transform-origin: 50% 100%; transform: rotate(7deg); }
|
|
35
|
+
|
|
36
|
+
.lively__ears svg {
|
|
37
|
+
display: block;
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
overflow: visible;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.lively__ear {
|
|
44
|
+
fill: var(--lively-body);
|
|
45
|
+
stroke: var(--lively-outline);
|
|
46
|
+
stroke-width: 2.4;
|
|
47
|
+
stroke-linejoin: round;
|
|
48
|
+
stroke-linecap: round;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.lively__ear--inner {
|
|
52
|
+
fill: var(--lively-accent);
|
|
53
|
+
stroke: none;
|
|
54
|
+
opacity: 0.85;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.lively-cat__muzzle {
|
|
58
|
+
fill: #eee5d9;
|
|
59
|
+
opacity: .82;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.lively-cat__whiskers {
|
|
63
|
+
position: absolute;
|
|
64
|
+
inset: 0;
|
|
65
|
+
z-index: 5;
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
overflow: visible;
|
|
68
|
+
animation: lively-cat-whiskers-float 3.8s ease-in-out infinite;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.lively-cat__whiskers svg {
|
|
72
|
+
display: block;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
75
|
+
overflow: visible;
|
|
76
|
+
filter: drop-shadow(0 1px 1px rgba(0,0,0,.18));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.lively-cat__whisker {
|
|
80
|
+
fill: none;
|
|
81
|
+
stroke: color-mix(in srgb, white 82%, var(--lively-outline));
|
|
82
|
+
stroke-width: 1.15;
|
|
83
|
+
stroke-linecap: round;
|
|
84
|
+
opacity: .9;
|
|
85
|
+
transform-box: fill-box;
|
|
86
|
+
transform-origin: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.lively-cat__whisker--l1,
|
|
90
|
+
.lively-cat__whisker--r3 { animation: lively-cat-whisker-drift-a 3.2s ease-in-out infinite; }
|
|
91
|
+
.lively-cat__whisker--l2,
|
|
92
|
+
.lively-cat__whisker--r2 { animation: lively-cat-whisker-drift-b 3.8s ease-in-out .25s infinite; }
|
|
93
|
+
.lively-cat__whisker--l3,
|
|
94
|
+
.lively-cat__whisker--r1 { animation: lively-cat-whisker-drift-c 3.5s ease-in-out .5s infinite; }
|
|
95
|
+
|
|
96
|
+
/* Whiskers are a face accessory, so emotions can pose them independently. */
|
|
97
|
+
.lively-mascot.is-emotion-00 .lively-cat__whiskers,
|
|
98
|
+
.lively-mascot.is-emotion-12 .lively-cat__whiskers {
|
|
99
|
+
animation: lively-cat-whiskers-droop 2.5s ease-in-out infinite;
|
|
100
|
+
}
|
|
101
|
+
.lively-mascot.is-emotion-10 .lively-cat__whiskers,
|
|
102
|
+
.lively-mascot.is-emotion-11 .lively-cat__whiskers {
|
|
103
|
+
animation: lively-cat-whiskers-alert .5s ease-in-out infinite alternate;
|
|
104
|
+
}
|
|
105
|
+
.lively-mascot.is-emotion-13 .lively-cat__whiskers {
|
|
106
|
+
animation: lively-cat-whiskers-puff .34s ease-in-out infinite alternate;
|
|
107
|
+
}
|
|
108
|
+
.lively-mascot.is-emotion-14 .lively-cat__whiskers,
|
|
109
|
+
.lively-mascot.is-emotion-37 .lively-cat__whiskers {
|
|
110
|
+
animation: lively-cat-whiskers-twitch .42s ease-in-out infinite;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Happy click: ears wiggle */
|
|
114
|
+
.lively-mascot.is-happy .lively__ears {
|
|
115
|
+
animation: lively-cat-ear-wiggle 0.5s ease-in-out;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* --- Tail: curved behind the body --- */
|
|
119
|
+
.lively__tail {
|
|
120
|
+
position: absolute;
|
|
121
|
+
bottom: 3cqw;
|
|
122
|
+
right: -14cqw;
|
|
123
|
+
width: 37cqw;
|
|
124
|
+
height: 42cqw;
|
|
125
|
+
transform-origin: 10% 100%;
|
|
126
|
+
animation: lively-cat-tail-sway 2.4s ease-in-out infinite;
|
|
127
|
+
z-index: -1;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.lively__tail svg {
|
|
131
|
+
display: block;
|
|
132
|
+
width: 100%;
|
|
133
|
+
height: 100%;
|
|
134
|
+
overflow: visible;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* The outer wrapper handles the broad wag; this inner motion lets the
|
|
138
|
+
curved portion breathe and gives the tip a gentle vertical response. */
|
|
139
|
+
.lively-cat__tail-motion {
|
|
140
|
+
transform-box: fill-box;
|
|
141
|
+
transform-origin: 4% 94%;
|
|
142
|
+
animation: lively-cat-tail-ripple 2.4s ease-in-out infinite;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.lively-cat__tail-path {
|
|
146
|
+
fill: none;
|
|
147
|
+
stroke: var(--lively-body);
|
|
148
|
+
stroke-width: 6.6;
|
|
149
|
+
stroke-linecap: round;
|
|
150
|
+
stroke-linejoin: round;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.lively-cat__tail-outline {
|
|
154
|
+
fill: none;
|
|
155
|
+
stroke: var(--lively-outline);
|
|
156
|
+
stroke-width: 8.2;
|
|
157
|
+
stroke-linecap: round;
|
|
158
|
+
stroke-linejoin: round;
|
|
159
|
+
opacity: 0.18;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.lively-cat__tail-tip {
|
|
163
|
+
fill: var(--lively-body);
|
|
164
|
+
stroke: var(--lively-outline);
|
|
165
|
+
stroke-width: 2;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.lively-cat__toe-lines {
|
|
169
|
+
fill: none;
|
|
170
|
+
stroke: var(--lively-outline);
|
|
171
|
+
stroke-width: .9;
|
|
172
|
+
stroke-linecap: round;
|
|
173
|
+
opacity: .72;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* Happy click: tail wags fast */
|
|
177
|
+
.lively-mascot.is-happy .lively__tail {
|
|
178
|
+
animation: lively-cat-tail-wag 0.3s ease-in-out 3;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* --- Whiskers: lines on the face --- */
|
|
182
|
+
.lively-face__whisker {
|
|
183
|
+
fill: none;
|
|
184
|
+
stroke: var(--lively-outline);
|
|
185
|
+
stroke-width: 1.2;
|
|
186
|
+
stroke-linecap: round;
|
|
187
|
+
opacity: 0.5;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* --- Nose: small triangle --- */
|
|
191
|
+
.lively-face__cat-nose {
|
|
192
|
+
fill: var(--lively-accent);
|
|
193
|
+
stroke: var(--lively-outline);
|
|
194
|
+
stroke-width: 1.2;
|
|
195
|
+
stroke-linejoin: round;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.lively-face__cat-nose-bridge {
|
|
199
|
+
fill: none;
|
|
200
|
+
stroke: var(--lively-outline);
|
|
201
|
+
stroke-width: 1.1;
|
|
202
|
+
stroke-linecap: round;
|
|
203
|
+
opacity: .8;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* --- Foot positioning for cat --- */
|
|
207
|
+
.lively-mascot--cat .lively__foot--l { left: 20cqw; }
|
|
208
|
+
.lively-mascot--cat .lively__foot--r { left: 58cqw; animation-delay: 0.8s; }
|
|
209
|
+
|
|
210
|
+
/* Cat paw shape override */
|
|
211
|
+
.lively-mascot--cat .lively-foot__body {
|
|
212
|
+
rx: 8;
|
|
213
|
+
ry: 5;
|
|
214
|
+
fill: var(--lively-body);
|
|
215
|
+
stroke: var(--lively-outline);
|
|
216
|
+
stroke-width: 1.3;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.lively-mascot--cat .lively-foot__shine { opacity: .62; }
|
|
220
|
+
|
|
221
|
+
@keyframes lively-cat-whiskers-float {
|
|
222
|
+
0%, 100% { transform: translateY(0); }
|
|
223
|
+
50% { transform: translateY(-1.5px); }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@keyframes lively-cat-whisker-drift-a {
|
|
227
|
+
0%, 100% { transform: rotate(0deg) translateY(0); }
|
|
228
|
+
50% { transform: rotate(-2deg) translateY(-1px); }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@keyframes lively-cat-whisker-drift-b {
|
|
232
|
+
0%, 100% { transform: rotate(0deg) translateY(0); }
|
|
233
|
+
50% { transform: rotate(1.5deg) translateY(1px); }
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@keyframes lively-cat-whisker-drift-c {
|
|
237
|
+
0%, 100% { transform: rotate(0deg) translateY(0); }
|
|
238
|
+
50% { transform: rotate(-1deg) translateY(1.5px); }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@keyframes lively-cat-whiskers-droop {
|
|
242
|
+
0%, 100% { transform: translateY(1px) rotate(0deg); }
|
|
243
|
+
50% { transform: translateY(3px) rotate(2deg); }
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@keyframes lively-cat-whiskers-alert {
|
|
247
|
+
from { transform: translateY(0) scale(1); }
|
|
248
|
+
to { transform: translateY(-1px) scale(1.035); }
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@keyframes lively-cat-whiskers-puff {
|
|
252
|
+
from { transform: translateX(0) scale(1); }
|
|
253
|
+
to { transform: translateX(-1px) scale(1.06, 1.02); }
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@keyframes lively-cat-whiskers-twitch {
|
|
257
|
+
0%, 100% { transform: rotate(0deg); }
|
|
258
|
+
35% { transform: rotate(-2deg); }
|
|
259
|
+
70% { transform: rotate(1.5deg); }
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* --- Cat-specific ear emotion animations --- */
|
|
263
|
+
.lively-mascot.is-emotion-11 .lively__ears { animation: lively-cat-ear-perk 0.6s ease-in-out infinite; }
|
|
264
|
+
.lively-mascot.is-emotion-13 .lively__ears { animation: lively-cat-ear-flatten 0.3s ease-in-out infinite; }
|
|
265
|
+
.lively-mascot.is-emotion-37 .lively__ears { animation: lively-cat-ear-nervous 0.4s ease-in-out infinite; }
|
|
266
|
+
.lively-mascot.is-emotion-00 .lively__ears { animation: lively-cat-ear-relax 4s ease-in-out infinite; }
|
|
267
|
+
|
|
268
|
+
/* --- Cat-specific tail emotion animations --- */
|
|
269
|
+
.lively-mascot.is-emotion-12 .lively__tail { animation: lively-cat-tail-droop 3s ease-in-out infinite; }
|
|
270
|
+
.lively-mascot.is-emotion-13 .lively__tail { animation: lively-cat-tail-puff 0.5s ease-in-out infinite; }
|
|
271
|
+
.lively-mascot.is-emotion-37 .lively__tail { animation: lively-cat-tail-tuck 0.6s ease-in-out infinite; }
|
|
272
|
+
|
|
273
|
+
/* --- Cat ear keyframes --- */
|
|
274
|
+
@keyframes lively-cat-ear-wiggle {
|
|
275
|
+
0%, 100% { transform: rotate(0); }
|
|
276
|
+
25% { transform: rotate(-4deg) translateY(-2px); }
|
|
277
|
+
75% { transform: rotate(4deg) translateY(-2px); }
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@keyframes lively-cat-ear-perk {
|
|
281
|
+
0%, 100% { transform: translateY(0) scaleY(1); }
|
|
282
|
+
50% { transform: translateY(-3px) scaleY(1.1); }
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@keyframes lively-cat-ear-flatten {
|
|
286
|
+
0%, 100% { transform: scaleY(1) rotate(0); }
|
|
287
|
+
50% { transform: scaleY(0.6) rotate(-5deg); }
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@keyframes lively-cat-ear-nervous {
|
|
291
|
+
0%, 100% { transform: rotate(0); }
|
|
292
|
+
25% { transform: rotate(-3deg); }
|
|
293
|
+
75% { transform: rotate(3deg); }
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@keyframes lively-cat-ear-relax {
|
|
297
|
+
0%, 100% { transform: rotate(0) scaleY(1); }
|
|
298
|
+
50% { transform: rotate(2deg) scaleY(0.9); }
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* --- Cat tail keyframes --- */
|
|
302
|
+
@keyframes lively-cat-tail-sway {
|
|
303
|
+
0%, 100% { transform: rotate(-5deg) translateY(0); }
|
|
304
|
+
50% { transform: rotate(10deg) translateY(-1px); }
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@keyframes lively-cat-tail-ripple {
|
|
308
|
+
0%, 100% { transform: rotate(0deg) scaleY(1); }
|
|
309
|
+
42% { transform: rotate(2.2deg) translateY(-1px) scaleY(.965); }
|
|
310
|
+
68% { transform: rotate(-1.1deg) translateY(.5px) scaleY(1.012); }
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
@keyframes lively-cat-tail-wag {
|
|
314
|
+
0%, 100% { transform: rotate(-5deg); }
|
|
315
|
+
50% { transform: rotate(15deg); }
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
@keyframes lively-cat-tail-droop {
|
|
319
|
+
0%, 100% { transform: rotate(0deg) translateY(0); }
|
|
320
|
+
50% { transform: rotate(-8deg) translateY(3px); }
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
@keyframes lively-cat-tail-puff {
|
|
324
|
+
0%, 100% { transform: rotate(-5deg) scaleY(1); }
|
|
325
|
+
50% { transform: rotate(10deg) scaleY(1.3); }
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
@keyframes lively-cat-tail-tuck {
|
|
329
|
+
0%, 100% { transform: rotate(0deg); }
|
|
330
|
+
50% { transform: rotate(-15deg) translateX(-4px); }
|
|
331
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lively-mascot · Cat Character
|
|
3
|
+
*
|
|
4
|
+
* A round cat with triangular ears, a curved tail, and whiskers.
|
|
5
|
+
* Registers itself with the global LivelyMascot SDK.
|
|
6
|
+
*
|
|
7
|
+
* Requires: lively-mascot.js (loaded before this script)
|
|
8
|
+
*/
|
|
9
|
+
(function () {
|
|
10
|
+
"use strict";
|
|
11
|
+
|
|
12
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
13
|
+
|
|
14
|
+
function svg(tag, attrs, children) {
|
|
15
|
+
var el = document.createElementNS(SVG_NS, tag);
|
|
16
|
+
if (attrs) for (var k in attrs) if (Object.prototype.hasOwnProperty.call(attrs, k)) el.setAttribute(k, String(attrs[k]));
|
|
17
|
+
if (children) for (var i = 0; i < children.length; i++) el.appendChild(children[i]);
|
|
18
|
+
return el;
|
|
19
|
+
}
|
|
20
|
+
function hEl(tag, attrs, children) {
|
|
21
|
+
var node = document.createElement(tag);
|
|
22
|
+
if (attrs) for (var k in attrs) {
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(attrs, k)) {
|
|
24
|
+
var v = attrs[k];
|
|
25
|
+
if (v === undefined || v === null || v === "") continue;
|
|
26
|
+
if (k === "class") node.className = String(v);
|
|
27
|
+
else if (k === "text") node.textContent = String(v);
|
|
28
|
+
else node.setAttribute(k, String(v));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (children) for (var i = 0; i < children.length; i++) node.appendChild(children[i]);
|
|
32
|
+
return node;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function renderCat(rig, rigEl) {
|
|
36
|
+
// --- Ears: tall, pointed cat ears ---
|
|
37
|
+
var ears = hEl("span", { class: "lively__ears", "aria-hidden": "true" });
|
|
38
|
+
var earLeft = svg("g", { class: "lively__ear-left" }, [
|
|
39
|
+
svg("path", { class: "lively__ear", d: "M1 30 C2 17 5 6 10 1 Q11 0 13 3 C18 14 20 24 20 30 C13 32 6 32 1 30 Z" }),
|
|
40
|
+
svg("path", { class: "lively__ear--inner", d: "M6 28 C6 19 8 10 10 6 Q11 5 12 7 C15 15 16 23 16 28 C12 29 9 29 6 28 Z" })
|
|
41
|
+
]);
|
|
42
|
+
var earRight = svg("g", { class: "lively__ear-right" }, [
|
|
43
|
+
svg("path", { class: "lively__ear", d: "M59 30 C58 17 55 6 50 1 Q49 0 47 3 C42 14 40 24 40 30 C47 32 54 32 59 30 Z" }),
|
|
44
|
+
svg("path", { class: "lively__ear--inner", d: "M54 28 C54 19 52 10 50 6 Q49 5 48 7 C45 15 44 23 44 28 C48 29 51 29 54 28 Z" })
|
|
45
|
+
]);
|
|
46
|
+
ears.appendChild(svg("svg", { viewBox: "0 0 60 32" }, [earLeft, earRight]));
|
|
47
|
+
rig.registerLeaf(ears, { useLeafAnim: false }); // cat drives ears via its own CSS
|
|
48
|
+
|
|
49
|
+
// --- Body ---
|
|
50
|
+
var body = hEl("div", { class: "lively-body lively-body--cat" });
|
|
51
|
+
rig.registerBody(body);
|
|
52
|
+
|
|
53
|
+
// --- Tail ---
|
|
54
|
+
var tail = hEl("span", { class: "lively__tail", "aria-hidden": "true" });
|
|
55
|
+
// The tail begins well inside the body silhouette. Its visible curve can
|
|
56
|
+
// therefore emerge from behind the flank instead of ending at the edge.
|
|
57
|
+
tail.appendChild(svg("svg", { viewBox: "0 0 52 58" }, [
|
|
58
|
+
svg("g", { class: "lively-cat__tail-motion" }, [
|
|
59
|
+
svg("path", { class: "lively-cat__tail-outline", d: "M-10 56 C-7 40, 0 25, 17 16 C28 10, 43 11, 46 20 C48 27, 42 32, 35 28" }),
|
|
60
|
+
svg("path", { class: "lively-cat__tail-path", d: "M-10 56 C-7 40, 0 25, 17 16 C28 10, 43 11, 46 20 C48 27, 42 32, 35 28" }),
|
|
61
|
+
svg("circle", { class: "lively-cat__tail-tip", cx: 35, cy: 28, r: 3.2 })
|
|
62
|
+
])
|
|
63
|
+
]));
|
|
64
|
+
|
|
65
|
+
// --- Face (shared) ---
|
|
66
|
+
var faceObj = LivelyMascot.buildFaceSvg(rig);
|
|
67
|
+
var face = faceObj.face;
|
|
68
|
+
|
|
69
|
+
// A small warm muzzle keeps the dark cat readable without making the
|
|
70
|
+
// cheeks look like a second pair of eyes.
|
|
71
|
+
face.insertBefore(svg("ellipse", { class: "lively-cat__muzzle", cx: 38, cy: 61, rx: 10, ry: 6 }), face.firstChild);
|
|
72
|
+
face.insertBefore(svg("ellipse", { class: "lively-cat__muzzle", cx: 62, cy: 61, rx: 10, ry: 6 }), face.firstChild);
|
|
73
|
+
|
|
74
|
+
// Cat nose: inverted triangle with a short philtrum.
|
|
75
|
+
face.appendChild(svg("path", { class: "lively-face__cat-nose-bridge", d: "M50 59 L50 63" }));
|
|
76
|
+
face.appendChild(svg("path", { class: "lively-face__cat-nose", d: "M46 57 Q50 55 54 57 L50 61 Z" }));
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// Floating whiskers are intentionally separate from the face so they can
|
|
80
|
+
// drift independently, like fine paper-cutout filaments in the air.
|
|
81
|
+
var whiskers = hEl("span", { class: "lively-cat__whiskers", "aria-hidden": "true" });
|
|
82
|
+
whiskers.appendChild(svg("svg", { viewBox: "0 0 100 100" }, [
|
|
83
|
+
svg("path", { class: "lively-cat__whisker lively-cat__whisker--l1", d: "M34 57 C24 53 17 50 9 50" }),
|
|
84
|
+
svg("path", { class: "lively-cat__whisker lively-cat__whisker--l2", d: "M33 61 C22 60 15 60 7 62" }),
|
|
85
|
+
svg("path", { class: "lively-cat__whisker lively-cat__whisker--l3", d: "M34 65 C24 67 18 70 11 74" }),
|
|
86
|
+
svg("path", { class: "lively-cat__whisker lively-cat__whisker--r1", d: "M66 57 C76 53 83 50 91 50" }),
|
|
87
|
+
svg("path", { class: "lively-cat__whisker lively-cat__whisker--r2", d: "M67 61 C78 60 85 60 93 62" }),
|
|
88
|
+
svg("path", { class: "lively-cat__whisker lively-cat__whisker--r3", d: "M66 65 C76 67 82 70 89 74" })
|
|
89
|
+
]));
|
|
90
|
+
rig.registerFaceAccessory("whiskers", whiskers);
|
|
91
|
+
rig.setFaceAccessory("whiskers");
|
|
92
|
+
|
|
93
|
+
body.appendChild(ears);
|
|
94
|
+
body.appendChild(faceObj.wrap);
|
|
95
|
+
body.appendChild(whiskers);
|
|
96
|
+
rigEl.appendChild(body);
|
|
97
|
+
rigEl.appendChild(tail);
|
|
98
|
+
|
|
99
|
+
// --- Feet ---
|
|
100
|
+
var feet = hEl("div", { class: "lively__feet" });
|
|
101
|
+
rig.registerFeet(feet);
|
|
102
|
+
var footL = hEl("span", { class: "lively__foot lively__foot--l" });
|
|
103
|
+
footL.appendChild(svg("svg", { viewBox: "0 0 22 16" }, [
|
|
104
|
+
svg("ellipse", { class: "lively-foot__body", cx: 11, cy: 10, rx: 10, ry: 6 }),
|
|
105
|
+
svg("ellipse", { class: "lively-foot__shine", cx: 8, cy: 7, rx: 3, ry: 1.8 }),
|
|
106
|
+
svg("path", { class: "lively-cat__toe-lines", d: "M7 10 Q7 8 8 7 M11 11 Q11 9 12 8 M15 10 Q15 8 16 7" })
|
|
107
|
+
]));
|
|
108
|
+
var footR = hEl("span", { class: "lively__foot lively__foot--r" });
|
|
109
|
+
footR.appendChild(svg("svg", { viewBox: "0 0 22 16" }, [
|
|
110
|
+
svg("ellipse", { class: "lively-foot__body", cx: 11, cy: 10, rx: 10, ry: 6 }),
|
|
111
|
+
svg("ellipse", { class: "lively-foot__shine", cx: 8, cy: 7, rx: 3, ry: 1.8 }),
|
|
112
|
+
svg("path", { class: "lively-cat__toe-lines", d: "M7 10 Q7 8 8 7 M11 11 Q11 9 12 8 M15 10 Q15 8 16 7" })
|
|
113
|
+
]));
|
|
114
|
+
feet.appendChild(footL);
|
|
115
|
+
feet.appendChild(footR);
|
|
116
|
+
rigEl.appendChild(feet);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Register cat character when SDK is available
|
|
120
|
+
if (typeof LivelyMascot !== "undefined") {
|
|
121
|
+
LivelyMascot.registerCharacter("cat", renderCat, "Cat", "0 0 100 100");
|
|
122
|
+
} else {
|
|
123
|
+
// SDK not yet loaded; defer registration
|
|
124
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
125
|
+
if (typeof LivelyMascot !== "undefined") {
|
|
126
|
+
LivelyMascot.registerCharacter("cat", renderCat, "Cat", "0 0 100 100");
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
})();
|