Skip to content

Commit

Permalink
remove gif capture since it's buggy
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Sep 20, 2024
1 parent a60b873 commit 64bc8c9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 81 deletions.
1 change: 0 additions & 1 deletion build/tools/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ copyAndWatch(
{ src: 'sample/**/*', dst: 'out' },
{ src: 'samples/**/*', dst: 'out' },
{ src: 'shaders/**/*', dst: 'out' },
{ src: 'third_party/**/*', dst: 'out' },
{ src: 'index.html', dst: 'out' },
],
{ watch }
Expand Down
8 changes: 0 additions & 8 deletions sample/alphaToCoverage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@
height: min(100vw, 100vh);
display: block;
}
#imggif {
position: fixed;
right: 0;
bottom: 0;
width: min(20vw, 20vh);
height: min(20vw, 20vh);
}
</style>
<script src="../../third_party/gif.js/gif.js"></script>
<script defer type="module" src="main.js"></script>
<script defer type="module" src="../../js/iframe-helper.js"></script>
</head>
<body>
<canvas></canvas>
<img id=imggif></img>
</body>
</html>
45 changes: 0 additions & 45 deletions sample/alphaToCoverage/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import showMultisampleTextureWGSL from './showMultisampleTexture.wgsl';
import renderWithAlphaToCoverageWGSL from './renderWithAlphaToCoverage.wgsl';
import { quitIfWebGPUNotAvailable } from '../util';

/* eslint @typescript-eslint/no-explicit-any: "off" */
declare const GIF: any; // from gif.js

const canvas = document.querySelector('canvas') as HTMLCanvasElement;
const adapter = await navigator.gpu?.requestAdapter();
const device = await adapter?.requestDevice();
Expand Down Expand Up @@ -37,9 +34,6 @@ const gui = new GUI();
Object.assign(config, kInitConfig);
gui.updateDisplay();
},
captureGif() {
void captureGif();
},
};

const settings = gui.addFolder('Settings');
Expand All @@ -55,7 +49,6 @@ const gui = new GUI();
alphaPanel.add(config, 'pause', false);

gui.add(buttons, 'initial').name('reset to initial');
gui.add(buttons, 'captureGif').name('capture gif (right click gif to save)');
}

//
Expand Down Expand Up @@ -201,41 +194,3 @@ function frame() {
}

requestAnimationFrame(frame);

async function captureGif() {
const size = Math.max(config.width, config.height) * 32;
const gif = new GIF({
workers: 4,
workerScript: '../../third_party/gif.js/gif.worker.js',
width: size,
height: size,
debug: true,
});

canvas.width = canvas.height = size;
const frames = [];
// Loop through all alpha values and render a frame
for (let alpha = 0; alpha <= kAlphaSteps; ++alpha) {
config.alpha = alpha;
render();
const dataURL = canvas.toDataURL();
// Only save the frame into the gif if it's different from the last one
if (dataURL !== frames[frames.length - 1]) {
frames.push(dataURL);
}
}
for (let i = 0; i < frames.length; ++i) {
const img = new Image();
img.src = frames[i];
gif.addFrame(img, {
delay: i == 0 || i == frames.length - 1 ? 2000 : 1000,
});
}

gif.on('finished', (blob) => {
const imggif = document.querySelector('#imggif') as HTMLImageElement;
imggif.src = URL.createObjectURL(blob);
console.log(imggif.src);
});
gif.render();
}
21 changes: 0 additions & 21 deletions third_party/gif.js/LICENSE.txt

This file was deleted.

3 changes: 0 additions & 3 deletions third_party/gif.js/gif.js

This file was deleted.

Loading

0 comments on commit 64bc8c9

Please sign in to comment.