小编Has*_*lam的帖子

如何将画布动画保存为gif或webm?

我已经编写了这个函数来捕获GIF的每个帧,但是输出非常滞后并且在数据增加时崩溃.有什么建议 ?

代码:

    function createGifFromPng(list, framerate, fileName, gifScale) {
            gifshot.createGIF({
                'images': list,
                'gifWidth': wWidth * gifScale,
                'gifHeight': wHeight * gifScale,
                'interval': 1 / framerate,
            }, function(obj) {
                if (!obj.error) {
                    var image = obj.image;
                    var a = document.createElement('a');
                    document.body.append(a);
                    a.download = fileName;
                    a.href = image;
                    a.click();
                    a.remove();
                }
            });
        }
/////////////////////////////////////////////////////////////////////////

function getGifFromCanvas(renderer, sprite, fileName, gifScale, framesCount, framerate) {
            var listImgs = [];
            var saving = false;
            var interval = setInterval(function() {
                renderer.extract.canvas(sprite).toBlob(function(b) {
                    if (listImgs.length >= framesCount) {
                        clearInterval(interval); …
Run Code Online (Sandbox Code Playgroud)

javascript html5 canvas gif three.js

7
推荐指数
2
解决办法
3063
查看次数

标签 统计

canvas ×1

gif ×1

html5 ×1

javascript ×1

three.js ×1