]> git.ardis.lu - ard.is/commitdiff
Add hidden effect 2
authorArdis Lu <ardisglu@gmail.com>
Sun, 8 Sep 2024 08:11:51 +0000 (01:11 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 8 Sep 2024 08:11:51 +0000 (01:11 -0700)
index.html

index 8375734ecce921443f236ddd2acd804b789af491..c9eadf16bcfd3aa26c607e1a623df31c58ad9298 100644 (file)
       font-family: monospace;
       font-size: clamp(1rem, 2.5dvi, 2rem);
       position: relative;
+      transition: translate 200ms, filter 200ms;
     }
 
-    #ascii-container button {
+    #ascii-container .effect {
       font-family: inherit;
       font-size: inherit;
       position: absolute;
-      left: 17.5ch;
-      bottom: 0;
       inline-size: 2ch;
       block-size: 2ch;
       border: none;
         border-radius: 2ch;
         animation: flicker 1s linear infinite alternate;
       }
+
+      &.color {
+        left: 17.5ch;
+        bottom: 0;
+      }
+
+      &.character {
+        left: 19.5ch;
+        top: 2.3ch;
+      }
     }
 
     @keyframes flicker {
       const currentFrame = Math.floor((timestamp - start) / msPerFrame);
       if (currentFrame >= frames.length) {
         asciiContainer.textContent = ascii;
-        asciiContainer.insertAdjacentElement('beforeend', button)
+        asciiContainer.insertAdjacentElement('beforeend', colorEffect);
+        asciiContainer.insertAdjacentElement('beforeend', translateEffect);
         return;
       }
       asciiContainer.textContent = frames[currentFrame];
     }
 
     // Add hidden effect
-    const button = document.createElement('button');
+    const colorEffect = document.createElement('button');
+    colorEffect.classList.add('effect', 'color');
     const highlightStyle = document.createElement('style');
     document.head.appendChild(highlightStyle);
-    button.addEventListener('click', e => {
+    colorEffect.addEventListener('click', e => {
       e.target.textContent = '!';
 
       if (CSS.highlights !== undefined) {
       }
     });
 
+    // Add hidden effect 2
+    const translateEffect = document.createElement('button');
+    translateEffect.classList.add('effect', 'character');
+    translateEffect.addEventListener('click', e => {
+      e.target.textContent = '!';
+
+      const xOffset = Math.floor(Math.random() * 5 + 5) * (Math.random() < 0.5 ? 1 : -1);
+      const yOffset = Math.floor(Math.random() * 5 + 5) * (Math.random() < 0.5 ? 1 : -1);
+      asciiContainer.style.setProperty('translate', `${xOffset}px ${yOffset}px`);
+      asciiContainer.style.setProperty('filter', `drop-shadow(${xOffset * -1}px ${yOffset * -1}px 4px hsl(216deg 50% 50%))`);
+    });
+
     // Inject obfuscated email. To block low-effort scraping.
     const addr = document.querySelector('address > a');
     addr.href = atob('bWFpbHRvOmFyZGlzQGFyZGlzbHUuZGV2');
This page took 0.03663 seconds and 4 git commands to generate.