)
}
}
)
(
}
{
)
)
(
)
(
(
{
}
)
(
)
}
)
)
{
(
(
)
)
}
)
(
}

Base36 Alphabet Animated

  1. const canvas = document.createElement('canvas')
  2. canvas.width = innerWidth * .5
  3. canvas.height = innerHeight * .5
  4. canvas.style.transformOrigin = '0 0'
  5. canvas.style.transform = 'scale(2, 2)'
  6. canvas.style.imageRendering = 'pixelated'
  7.  
  8. document.body.append(canvas)
  9. const c = canvas.getContext('2d')
  10.  
  11. // letters defined in base36
  12. const alphabet = ['', '67erkgi', 'e3j6dss', '75rue4u', 'c5ltok8', '75s2tji',
  13.   '75s2tjk', '75rugj2', '95yfnf6', '21blls4', '10nt5xo', '973it1u',
  14.   '85aef4u', '59lu6nl', 'cnz0hbn', '67ej51o', '67eq49c', '67ej53e',
  15.   '67eq7gy', '66978m4', '6ywdqpw', '95y780c', '53b00as', '8nmdpyi',
  16.   '5374thm', '53avnus', '6xsfdam'
  17. ]
  18.  
  19. function drawBase36(num, xp, yp) {
  20.   num = alphabet[num]
  21.  
  22.   let binaryString = parseInt(num, 36).toString(2).padStart(35, '0');
  23.  
  24.   for (let i = 0; i < 35; i++) {
  25.     if (binaryString.charAt(i) === '1') {
  26.       const x = (i % 5) + xp;
  27.       const y = Math.floor(i / 5) + yp;
  28.       c.fillRect(x, y, 1, 1); 
  29.     }
  30.   }
  31. }
  32.  
  33. function letter(char, col, x, y, scale = 1, rotation = 0) {
  34.   c.fillStyle = col
  35.   c.translate(x, y)
  36.   c.scale(scale, scale)
  37.   c.rotate(rotation)
  38.  
  39.   drawBase36(char, 0, 0);
  40.   c.setTransform(1, 0, 0, 1, 0, 0)
  41. }
  42.  
  43. let NUM = 100
  44. let ps = []
  45. for (let i = 0; i < NUM; i++) {
  46.   let hr = 180 + Math.random() * 50 - 25;
  47.   let ss = 100
  48.   let bb = 50
  49.   if (Math.random() < .5) {
  50.     hr = 30 + Math.random() * 50 - 25;
  51.     ss = 100
  52.     bb = 40
  53.   }
  54.   const col = `hsl(${hr}, ${ss}%, ${bb}%)`;
  55.   const p = [
  56.     1 + ~~(Math.random() * alphabet.length),
  57.     col,
  58.     Math.random() * canvas.height, 
  59.     Math.random() * (canvas.width + 200),
  60.     1 + Math.random() * Math.random() * 10, Math.random() * 7
  61.   ]
  62.   p.props = { 
  63.     vx: Math.random() * 1 - .5,
  64.     r: .01 * Math.random() - 0.005
  65.   }
  66.   letter(...p)
  67.   ps.push(p)
  68. }
  69.  
  70. function draw() {
  71.   c.fillStyle = 'rgba(91, 34, 0, .05)'
  72.   c.fillRect(0, 0, canvas.width, canvas.height)
  73.  
  74.   for (let i = 0; i < NUM; i++) {
  75.     const p = ps[i]
  76.     p[2] += p.props.vx;
  77.     p[5] += p.props.r
  78.     letter(...p)
  79.   } 
  80.  
  81.   c.fillStyle = 'rgba(0, 255, 255, 1)'
  82.   c.scale(1, 1)
  83.  
  84.   for (let i = 0; i < alphabet.length; i++) {
  85.     drawBase36(i, i * 10, 10);
  86.   }
  87.   c.setTransform(1, 0, 0, 1, 0, 0)
  88.  
  89.   requestAnimationFrame(draw)
  90. }
  91. draw()

This alphabet is something I drew manually in the 2000s – then at some point wrote this snippet on actionsnippet. Basically each letter is a 5×7 binary number and I store these in base36 for no particular reason 😀

Flun Draw

  1. const canvas = document.createElement('canvas')
  2. const c = canvas.getContext('2d')
  3.  
  4. canvas.width = innerWidth * 2
  5. canvas.height = innerHeight * 2
  6. document.body.append(canvas)
  7. canvas.style.width = innerWidth + 'px'
  8. canvas.style.height = innerHeight + 'px'
  9. c.fillStyle = 'white'
  10. c.fillRect(0, 0, canvas.width, canvas.height)
  11.  
  12. const flun = (
  13.   ax = innerWidth,
  14.   ay = innerHeight,
  15.   r = 0,
  16.   x = 0, y = 0,
  17.   t = 0,
  18.   dt = 0,
  19.   spin = 0,
  20.   spinc = .1,
  21.   rinc = 0,
  22.   col = 'black',
  23.   hist = []
  24. ) => {
  25.  
  26.   const init = () => {
  27.     dt = Math.random() * Math.PI * 2
  28.     r = 0
  29.     rinc = Math.random() * 1
  30.     spinc = Math.random() * .01 - .005
  31.     col = ['black', 'white', 'rgba(0, 0, 0, 0.2)']
  32.       [~~(Math.random() * 3)]
  33.   }
  34.   init()
  35.  
  36.   return () => {
  37.  
  38.     spin += spinc
  39.     if (Math.random() < .005) {
  40.       init()
  41.     } else {
  42.       r += rinc
  43.     }
  44.  
  45.     if (Math.random() < .01) {
  46.       ax = x
  47.       ay = y
  48.       const inside = ax > 0 &&
  49.         ax < canvas.width &&
  50.         ay > 0 &&
  51.         ay < canvas.height
  52.       if (!inside) {
  53.         const p = hist[~~(Math.random() * hist.length)]
  54.         ax = p[0]
  55.         ay = p[1]
  56.       }
  57.       init()
  58.     } 
  59.  
  60.     t += (dt - t) / 22
  61.  
  62.     x = ax + Math.cos(t + spin) * r
  63.     y = ay + Math.sin(t + spin) * r
  64.  
  65.     if (x > 0 && x < canvas.width &&
  66.       y > 0 && y < canvas.height) {
  67.       hist.push([x, y])
  68.     }
  69.  
  70.     c.fillStyle = col
  71.     c.fillRect(x, y, 4, 4)
  72.   }
  73. }
  74.  
  75. const f = flun()
  76.  
  77. setInterval(() => {
  78.   for (let i = 0; i < 20; i++) f()
  79. }, 16)

Just randomly coded this one morning for a short – simple – but never did this exact motion before. It looks surprisingly organic and occasionally draws things that look like faces and other objects

snippet.zone /// {s/z}