1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
| <p style="text-align: center">或者来养一只小猫咪吧~</p> <div class="wrapper"> <div class="innerWrapper"> <svg viewBox="0 0 158.82 186.47"><g id="outline"><path id="main-tamago" d="M23.5,104.55l.88,14.21a55.29,55.29,0,0,0,4,17.52l5.16,12.64a55.37,55.37,0,0,0,12.88,19L50.68,172a55.08,55.08,0,0,0,18.61,11.78l11.36,4.33a55.39,55.39,0,0,0,19.65,3.61h5.25A55.3,55.3,0,0,0,121,189.45l7.79-2.27A55.37,55.37,0,0,0,146,178.72l3.91-2.87a55.31,55.31,0,0,0,13.41-14l5.37-8.11a55,55,0,0,0,6.78-14.38l4-13a55.35,55.35,0,0,0,2.22-11.55l.38-4.62a55,55,0,0,0-.34-12.23L180,85.52A56.06,56.06,0,0,0,177.42,75l-5.07-14.56a55.22,55.22,0,0,0-4.4-9.57L163.37,43A55.77,55.77,0,0,0,157,34.12l-5.61-6.34a55,55,0,0,0-12.53-10.53L133.5,14a55.51,55.51,0,0,0-10.07-4.84l-1.7-.62a55.31,55.31,0,0,0-18.81-3.3h0A55,55,0,0,0,86.61,7.67l-.42.13a55.32,55.32,0,0,0-13,5.93L67.68,17.2a55.08,55.08,0,0,0-11.05,9.08l-6.83,7.3a55.77,55.77,0,0,0-7.9,10.8L34.44,57.73A55.17,55.17,0,0,0,29,71.62L25,88.1A55.22,55.22,0,0,0,23.5,104.55Z" transform="translate(-23.4 -5.2)" style="fill:rgb(241, 195, 98)"/></g><g id="light"><path d="M138.18,42.31l-1.7,13.12,16.93,12.48-2.5,18.59,4.81,12.85a5.49,5.49,0,0,0,3.82,3.37h0a5.42,5.42,0,0,0,6.08-2.79l2-3.87a5.53,5.53,0,0,0,.59-2l1.23-14a5.58,5.58,0,0,0-.07-1.47l-2.5-13.5a5.57,5.57,0,0,0-.49-1.44l-4.92-9.84a5.36,5.36,0,0,0-.69-1.06l-9-10.75a5.4,5.4,0,0,0-1.36-1.16l-4-2.45A5.43,5.43,0,0,0,138.18,42.31Z" transform="translate(-23.4 -5.2)" style="fill:#fff;opacity:0.36"/></g><g id="darkshadowy"><path d="M76.27,9.36" transform="translate(-23.4 -5.2)" style="fill:none;stroke:red;stroke-miterlimit:10"/><g style="opacity:0.21"><path d="M73.22,13.73,67.68,17.2a55.08,55.08,0,0,0-11.05,9.08l-6.83,7.3a55.77,55.77,0,0,0-7.9,10.8L34.44,57.73A55.17,55.17,0,0,0,29,71.62L25,88.1a55.22,55.22,0,0,0-1.47,16.45l.88,14.21a55.29,55.29,0,0,0,4,17.52l5.16,12.64a55.37,55.37,0,0,0,12.88,19L50.68,172a55,55,0,0,0,13.23,9.39,5.21,5.21,0,0,0,.89-3.91c-.32-2.44.83-10.25-9.12-18.19-9.15-7.3-11.92-8.62-14.71-13.32-2.29-3.87-3-7.29-4.16-13.32a86.46,86.46,0,0,1-1.39-16.93A126.47,126.47,0,0,1,36,101c.37-3.78.77-6,4.16-22.2,3.14-15,3.39-16,4.16-18,1-2.51,3.41-7.22,8.33-16.65,2.73-5.23,3.79-7.09,5.55-9.43a58.59,58.59,0,0,1,8-8.6c3.88-3.43,4.39-3,6.38-5.27.76-.85,4.84-5.57,5.06-9.51C76.15,12,74.66,12.83,73.22,13.73Z" transform="translate(-23.4 -5.2)" style="fill:#150d00"/></g></g><g id="inner-outline"><polygon points="36.5 79.91 24.84 109.33 36.5 126.81 34 136.52 47.6 147.34 62.86 142.9 76.45 154 93.66 143.46 114.75 147.06 125.84 114.6 133.34 106 122.52 84.08 124.73 64.65 108.92 52.44 96.99 59.1 70.35 50.22 55.09 57.72 38.44 56.05 36.5 79.91" style="fill:#fdffdf"/></g></svg>
<canvas class="cnvs"></canvas> <button id="callbutton"></button> </div> </div> <style> .wrapper { width: 100%; height: 100%; margin-top: 8px; display: flex; justify-content: center; align-items: center; } .innerWrapper { width: 200px; position: relative; } .innerWrapper svg { width: 200px; } .cnvs { width:80px; height:80px; background-color: rgba(60, 75, 60, 0.3); position: absolute; top: 80px; left: 60px; border-radius: 10px; box-shadow: 5px 4px 0px 1px rgba(40, 55, 40, 0.4) inset; } #callbutton { position: absolute; top: 194px; left: 85px; width: 38px; height: 38px; border-radius: 40%; background-color: #fdffdf; } #callbutton:focus { outline: 0; } #callbutton:active { background-color: #e0e2c9; box-shadow: -0.1px -0.5px 0px 2px #00000033; } </style> <script> const cvs = document.querySelector(".cnvs"); const size = 110; cvs.width = size; cvs.height = size; const ctx = cvs.getContext("2d"); const pxSize = 2; const sleepingCat = ` xx...xx........x x.xxx.x........x x.....x.......x. x.x.x.xxxxx..x.. x.....x....xxx.. .x...x.....x.... ..xxxx.....x.... ....xxxxxxx..... `; const standingCatToLeft = ` xx...xx........x x.xxx.x........x x.....x.......x. x.x.x.xxxxx..x.. x.....x....xxx.. .x...x.....x.... ..xxxx.....x.... ....xxxxxxx..... .....x.x.xxx.... .....x.x.x.x.... `; const standingCatToLeftPose2 = ` xx...xx........x x.xxx.x........x x.....x.......x. x.x.x.xxxxx..x.. x.....x....xxx.. .x...x.....x.... ..xxxx.....x.... ....xxxxxxx..... ....x.x.xxx..... ...x..x.x..x.... `; const sleepZSml = ` xx .x. .xx `; const sleepZMed = ` xxx. ..x. .x.. .xxx `; const sleepZLarge = ` xxxx. ..x.. .x... .xxxx `; let state = { type: "walk", x: 0 }; function drawArt(px, py, str, flip, col = "rgb(60, 75, 60)") { const lines = str.split("\n"); for (let y = 0; y < lines.length; y++) { let chars = lines[y].split(""); if (flip) chars.reverse(); for (let x = 0; x < chars.length; x++) { if (chars[x] === "x") drawRect(x + px, y + py, col, true); } } } function drawRect(x, y, col = "black", fill = false) { if (fill) { ctx.fillStyle = col; ctx.fillRect(x * pxSize, y * pxSize, pxSize, pxSize); return; } ctx.strokeStyle = col; ctx.fillStyle = ""; ctx.beginPath(); ctx.lineWidth = "1"; ctx.rect(x * pxSize, y * pxSize, pxSize, pxSize); ctx.stroke(); } function clear() { ctx.clearRect(0, 0, size, size); } function drawGrid() { let gridRows = Math.floor(size / pxSize); for (let i = 0; i < gridRows; i++) { for (let j = 0; j < gridRows; j++) { drawRect(j * 2, i * 2, "blue", false); } } } function refresh() { clear(); switch (state.type) { case "sleep": { sleepAnimation(); } break; case "stand": { standAnimation(); } break; case "walk": { walkAnimation(); } break; default: } } function sleepAnimation() { if (state.t === undefined) state.t = 0; drawArt(20, 32, sleepingCat); if (state.t >= 1) drawArt(28, 27, sleepZSml); if (state.t >= 2) drawArt(32, 22, sleepZMed); if (state.t >= 3) drawArt(36, 18, sleepZLarge); state.t = (state.t + 1) % 4; setTimeout(refresh, 500); } function standAnimation() { if (state.t === undefined) state.t = 0; if (state.t < 4) drawArt(20 + state.x, 30, standingCatToLeft, true); else drawArt(20 + state.x, 30, standingCatToLeftPose2, true); state.t++; if (state.t > 8) state.t -= 8; state.x += 1; setTimeout(refresh, 50); } function walkAnimation() { if (state.t === undefined) state.t = 0; if (state.dir === undefined) state.dir = "left"; const flip = state.dir === "right"; if (state.t < 4) drawArt(20 + state.x, 30, standingCatToLeft, flip); else drawArt(20 + state.x, 30, standingCatToLeftPose2, flip); state.t++; if (state.t > 8) state.t -= 8; state.x += state.dir === "left" ? -1 : 1; if (state.dir === "left" && state.x < -10) state.dir = "right"; if (state.dir === "right" && state.x > 10) state.dir = "left"; setTimeout(refresh, 100); } refresh(); var elem; function easeInOut(t) { const sqt = t ** 2; return sqt / (2.0 * (sqt - t) + 1.0); } var elem; callbutton=document.getElementById("callbutton") callbutton.addEventListener("click", function(){ if (!elem) elem = document.querySelector("#main-tamago"); if (state.type === "sleep") { state = { type: "walk", x: 0 }; elem.style.fill = 'rgb(241, 195, 98)'; } else { state = { type: "sleep" }; elem.style.fill = 'rgb(98, 144, 241)'; } }); </script>
|