JasonYao / JasonYao.github.io

My personal site at jasonyao.com using Hugo
https://www.jasonyao.com
GNU General Public License v3.0
1 stars 0 forks source link

easter egg: bad apple in favicon #53

Open JasonYao opened 1 year ago

JasonYao commented 1 year ago

This is a godawful, terrible, and useless to society idea.

So naturally I wanna see if it'd be possible. General user flow would be:

  1. User goes to my website, inputs some variant of konami code (up, up, down, down, left, right, left, right, B, A and RETURN could do the trick
  2. This fetches a compressed data pack of Bad Apple video in bit-map form (since it's a bitone already)
    • We get this by exploding out the mp4 frame by frame at 24 frames per second, decimating each image to the resolution desired for favicons.
    • Then, for each frame, we pack it into a buffer where each bit represents a pixel, so 4 bytes (for a 16 x 16 image size, there's 256 pixels, divided by 8 bits in a byte for 32 bytes of binary data for a single frame)
  3. Upon reading this flat video content buffer, we process (iterate by 32 byte intervals) through it, generating an image in-memory
  4. We then begin calling whatever it is that updates the favicon every 1s / 24 frames = 0.041s per frame (might wanna time how long the favicon update takes). Alternatively, we could just swap the image the favicon is pointing to every 0.041s, and keep the favicon link stable (not sure if favicon is just cached though)

Open questions to address at the start here

Step 1 can be done with an event listener, step 2 just with an API call to download bad apple which can be done pretty easily. Step 3 is an unkown, and there's a question of timing in step4 where we want to know how long the favicon update took.

JasonYao commented 1 year ago

looks like 100ms it won't update, 150 seems to work, and 125 might work with a few frame drops. At:

Let's say we go with 30s of bad apple to start.

150ms interval

150ms interval time: 1000ms / 150ms = 6.6666 frames per second 30s of content 6.6666 frames per second = 200 frames 200 frames 32 bytes per frame = 6400 bytes

125ms interval

125ms interval time: 1000ms / 125ms = 8 frames per second 30s of content 8 frames per second = 240 frames 240 frames 32 bytes per frame = 7,680 bytes

JasonYao commented 1 year ago

https://stackoverflow.com/a/5568484 might have a mechanism for us to have a data link instead of a naive href, enabling us to keep this all in memory.

With that, we've shown that with the bare minimum capabilities, this project is feasible.

JasonYao commented 1 year ago

split this into 2:

article: "playing bad apple in favicon"

build log: talk through stages:

  1. Enumerating Cknown unknowns (rendering speed of favicons etc from above)
  2. building out a throwaway barebones demo that only tests for what i'm looking for
  3. building out the image buffer script generation (can parameterize decimation size & frame rate)
  4. building out buffer frame extractor that iterates over the image buffer, and testing that it works for a few frames
  5. integrating this into my personal site
JasonYao commented 1 year ago

stage 3 notes

JasonYao commented 1 year ago

alternatives to mention: