[GIF] GIF Loop Coder - Introduction

介绍使用 GIFLoopCoder 制作循环动画 GIF 的方法,包括如何利用 JavaScript 和 HTML5 Canvas 添加对象到动画列表、设置动画属性及保存为动画 GIF。通过示例展示了创建动态元素及多星形图案的技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Introducing the program, GIF Loop Coder, which allows you to make looping animated gifs (and other types of animations) using JavaScript and HTML5 Canvas. We'll cover the basic UI and syntax of how to add objects to the animation list, animate them and save the result as an animated gif.

 

function onGLC(glc) {
    glc.loop();
//     glc.size(400, 400);
//     glc.setDuration(5);
//     glc.setFPS(20);
//     glc.setMode('single');
//     glc.setEasing(false);
    var list = glc.renderList,
        width = glc.w,
        height = glc.h,
        color = glc.color;

    // your code goes here:

    list.addCircle({
        x:width/2,
        y:height/2,
        radius:150,
        fillStyle:"yellow",
        stroke: true,
        strokeStyle:"red",
        lineWidth: 20
    });
    
}

 

Make it move:

To do that you can pass array to the props:

function onGLC(glc) {
    glc.loop();
//     glc.size(400, 400);
//     glc.setDuration(5);
//     glc.setFPS(20);
//     glc.setMode('single');
//     glc.setEasing(false);
    var list = glc.renderList,
        width = glc.w,
        height = glc.h,
        color = glc.color;

    // your code goes here:

    list.addCircle({
        x:width/2,
        y:height/2,
        radius:[100, 150],
        fillStyle: ["green", "yellow"],
        stroke: true,
        strokeStyle: ["yellow", "red"],
        lineWidth: [12, 20]
    });
    
}

Create Mutli stars:

function onGLC(glc) {
    glc.loop();
//     glc.size(400, 400);
//     glc.setDuration(5);
//     glc.setFPS(20);
//     glc.setMode('single');
//     glc.setEasing(false);
    var list = glc.renderList,
        width = glc.w,
        height = glc.h,
        color = glc.color;

    // your code goes here:

/*    list.addCircle({
        x:width/2,
        y:height/2,
        radius:[100, 150],
        fillStyle: ["green", "yellow"],
        stroke: true,
        strokeStyle: ["yellow", "red"],
        lineWidth: [12, 20]
    });*/
    
    for(var i = 0; i < 100; i++ ){
         list.addStar({
            x: Math.random() * width,
            y: Math.random() * height,
            outerRadius: 30 + Math.random() * 30,
            innerRadius: 10 + Math.random() * 20,
            fillStyle: color.randomRGB(),
            rotation: [0,120]
        })
    }
}

转载于:https://www.cnblogs.com/Answer1215/p/5688841.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值