當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript GifWriter.addFrame方法代碼示例

本文整理匯總了TypeScript中omggif.GifWriter.addFrame方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript GifWriter.addFrame方法的具體用法?TypeScript GifWriter.addFrame怎麽用?TypeScript GifWriter.addFrame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在omggif.GifWriter的用法示例。


在下文中一共展示了GifWriter.addFrame方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: gen_anim

function gen_anim() {
    // The loop parameter is the number of times to loop, or 0 for forever.
    // A value of 1 will play twice (first time, and then one loop time).
    // To play only once do not specify loop or pass null.
    const gf = new omggif.GifWriter(buf, 2, 2, { loop: 1 });
    gf.addFrame(0, 0, 2, 2, [0, 1, 1, 0], { palette: [0xff0000, 0x0000ff] });
    gf.addFrame(0, 0, 2, 2, [1, 0, 0, 1], {
        palette: [0xff0000, 0x0000ff],
        delay: 10,
    }); // Delay in hundredths of a sec (100 = 1s).
    return gf.end();
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:12,代碼來源:omggif-tests.ts

示例2: gen_gray_strip

function gen_gray_strip() {
    const gf = new omggif.GifWriter(buf, 256, 1);
    const palette = [];
    const indices = [];
    for (let i = 0; i < 256; ++i) {
        palette.push((i << 16) | (i << 8) | i);
        indices.push(i);
    }
    gf.addFrame(0, 0, 256, 1, indices, { palette });
    return gf.end();
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:11,代碼來源:omggif-tests.ts

示例3: gen_block256

// with lzw block of 256.
// see: https://github.com/deanm/omggif/issues/5
function gen_block256() {
    const width = 4840;
    const gf = new omggif.GifWriter(buf, width, 1, {
        palette: [0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000],
    });
    const stream = Array(width);
    for (let i = 0; i < width; ++i) stream[i] = i & 0x7;
    gf.addFrame(0, 0, width, 1, stream, { transparent: 0 });
    const data = buf.slice(0, gf.end());
    // Make sure it decodes.
    const gr = new omggif.GifReader(data);
    const frameInfo = gr.frameInfo(0);
    return frameInfo;
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:16,代碼來源:omggif-tests.ts

示例4: gen_color_strip

// More than 8-bit color (via tiling of several frames).  Browsers seem to
// treat this as an animation though, with an enforced minimum time between
// frames which makes it animated instead of the intended static image.
function gen_color_strip() {
    const gf = new omggif.GifWriter(buf, 256, 256, {
        palette: [0x000000, 0xff0000],
        background: 1,
    });

    const indices = [];
    for (let i = 0; i < 256; ++i) indices.push(i);

    for (let j = 0; j < 256; ++j) {
        const palette = [];
        for (let i = 0; i < 256; ++i) palette.push((j << 16) | (i << 8) | i);
        gf.addFrame(0, j, 256, 1, indices, { palette, disposal: 1 });
    }
    return gf.end();
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:19,代碼來源:omggif-tests.ts

示例5: gen_static_global

function gen_static_global() {
    const gf = new omggif.GifWriter(buf, 2, 2, { palette: [0xff0000, 0x0000ff] });
    gf.addFrame(0, 0, 2, 2, [0, 1, 1, 0]);
    return gf.end();
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:omggif-tests.ts

示例6: gen_empty_white

// 1x1 white, generates the same as Google's 35 byte __utm.gif, except for some
// reason that I'm not sure of they set their background index to 255.
function gen_empty_white() {
    const gf = new omggif.GifWriter(buf, 1, 1, { palette: [0xffffff, 0x000000] });
    gf.addFrame(0, 0, 1, 1, [0]);
    return gf.end();
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:omggif-tests.ts


注:本文中的omggif.GifWriter.addFrame方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。