NoahIsARider commited on
Commit
4c899cf
·
1 Parent(s): d806e6d

inline the reference plates so the analysis canvas is never tainted by a cross-origin asset

Browse files
README.md CHANGED
@@ -64,4 +64,4 @@ a −16 LUFS master.
64
  - `synth.js` — image analysis, synthesis, WAV encoding
65
  - `panels.js` — the four analysis plates
66
  - `app.js` — interface wiring
67
- - `examples/` — four original reference plates
 
64
  - `synth.js` — image analysis, synthesis, WAV encoding
65
  - `panels.js` — the four analysis plates
66
  - `app.js` — interface wiring
67
+ - `examples.js` — the four reference plates, inlined as data URIs
app.js CHANGED
@@ -14,12 +14,7 @@
14
  const readEl = $('#readouts');
15
  const canvases = [...document.querySelectorAll('#sheet .plate')];
16
 
17
- const EXAMPLES = [
18
- ['examples/misty_forest.jpg', 'I / fog lattice'],
19
- ['examples/brutalist.jpg', 'II / concrete diagonals'],
20
- ['examples/dusk_ocean.jpg', 'III / still water'],
21
- ['examples/autumn_canopy.jpg', 'IV / crimson field'],
22
- ];
23
 
24
  let current = null; // HTMLImageElement
25
  let currentUrl = null;
@@ -43,16 +38,13 @@
43
  return img;
44
  }
45
 
46
- EXAMPLES.forEach(([src, name], i) => {
47
  const b = document.createElement('button');
48
  b.innerHTML = `<img alt="${name}" src="${src}"><span>${name}</span>`;
49
  b.addEventListener('click', async () => {
50
  [...platesEl.children].forEach(c => c.classList.remove('active'));
51
  b.classList.add('active');
52
- const img = await loadImage(src);
53
- setImage(img);
54
- if (currentUrl) URL.revokeObjectURL(currentUrl);
55
- currentUrl = null;
56
  });
57
  platesEl.appendChild(b);
58
  });
@@ -125,8 +117,8 @@
125
  goEl.addEventListener('click', transmit);
126
 
127
  // default plate so the instrument is never empty
128
- loadImage(EXAMPLES[2][0]).then(img => {
129
  platesEl.children[2].classList.add('active');
130
  setImage(img);
131
- }).catch(() => {});
132
  })();
 
14
  const readEl = $('#readouts');
15
  const canvases = [...document.querySelectorAll('#sheet .plate')];
16
 
17
+ const EXAMPLES = PLATES_DATA; // [label, dataURI] pairs, see examples.js
 
 
 
 
 
18
 
19
  let current = null; // HTMLImageElement
20
  let currentUrl = null;
 
38
  return img;
39
  }
40
 
41
+ EXAMPLES.forEach(([name, src], i) => {
42
  const b = document.createElement('button');
43
  b.innerHTML = `<img alt="${name}" src="${src}"><span>${name}</span>`;
44
  b.addEventListener('click', async () => {
45
  [...platesEl.children].forEach(c => c.classList.remove('active'));
46
  b.classList.add('active');
47
+ setImage(await loadImage(src));
 
 
 
48
  });
49
  platesEl.appendChild(b);
50
  });
 
117
  goEl.addEventListener('click', transmit);
118
 
119
  // default plate so the instrument is never empty
120
+ loadImage(EXAMPLES[2][1]).then(img => {
121
  platesEl.children[2].classList.add('active');
122
  setImage(img);
123
+ }).catch(err => console.error('plate load failed', err));
124
  })();
examples.js ADDED
The diff for this file is too large to render. See raw diff
 
examples/autumn_canopy.jpg DELETED

Git LFS Details

  • SHA256: 5cec8e5714a533872450a6eec01171492674f4d446566ecc314143c57ad197ce
  • Pointer size: 132 Bytes
  • Size of remote file: 1.31 MB
examples/brutalist.jpg DELETED

Git LFS Details

  • SHA256: 6f8f10c8431dc0ed0d84261fd514fceb1913f988f9b02c5bfd85d3a4fbce87a4
  • Pointer size: 132 Bytes
  • Size of remote file: 1.44 MB
examples/dusk_ocean.jpg DELETED

Git LFS Details

  • SHA256: f2aedc2c4dfaf07a75696c593ab5106d4b1c6335f69735a1324806d9e5c049a7
  • Pointer size: 131 Bytes
  • Size of remote file: 700 kB
examples/misty_forest.jpg DELETED

Git LFS Details

  • SHA256: 3280188060d473402f8de79f99dcfc63ab1fcbfecb02331757806e1fb4c1502a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.13 MB
index.html CHANGED
@@ -65,6 +65,7 @@
65
  </footer>
66
 
67
  </div>
 
68
  <script src="synth.js"></script>
69
  <script src="panels.js"></script>
70
  <script src="app.js"></script>
 
65
  </footer>
66
 
67
  </div>
68
+ <script src="examples.js"></script>
69
  <script src="synth.js"></script>
70
  <script src="panels.js"></script>
71
  <script src="app.js"></script>