2020年1月2日 星期四

GIF教你怎用

下載GIF library


下載後解壓縮
到電腦文件下面有processing
點入後
再點入libraries資料夾
把你下載後的資料夾直接丟進去
就可以在processing內
打程式導入GIF嘞

範例
import gifAnimation.*; GifMaker gif; void setup(){ //插入你的初始化程序 setup_(); } void draw(){ //插入你的draw代码 draw_(); } void setup_(){
background(255); gif = new GifMaker(this,"gif.gif"); gif.setRepeat(0); //设置Gif重覆播放的次数,0为循環播放 gif.setDelay(40); //設置之間的延迟时间,單位毫秒。数值為40时,為25(1000/40)。 } void draw_(){ if(frameCount % 1 == 0){ //每間隔多少楨,寫入一次(相當於改變播放速率) gif.addFrame(); } } void mousePressed(){ gif.finish(); //導出Gif }

範例二
import gifAnimation.*; PImage[] animation; Gif loopingGif; Gif nonLoopingGif; boolean pause = false; public void setup() { size(400, 200); frameRate(100); // create the GifAnimation object for playback loopingGif = new Gif(this, "idle.gif"); loopingGif.loop(); nonLoopingGif = new Gif(this, "idle.gif"); nonLoopingGif.play(); // create the PImage array for the interactive display animation = Gif.getPImages(this, "idle.gif"); } void draw() { background(255 / (float)height * mouseY); image(loopingGif, 10, height / 2 - loopingGif.height / 2); image(nonLoopingGif, width/2 - nonLoopingGif.width/2, height / 2 - nonLoopingGif.height / 2); image(animation[(int) (animation.length / (float) (width) * mouseX)], width - 10 - animation[0].width, height / 2 - animation[0].height / 2); } void mousePressed() { nonLoopingGif.play(); } void keyPressed() { if (key == ' ') { if (pause) { nonLoopingGif.play(); loopingGif.play(); pause = false; } else { nonLoopingGif.pause(); loopingGif.pause(); pause = true; } } }

沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

回顧這學期的作品:  期中作業:LANDING:PLANET 賣點&特點: 炫麗的特效 物理(星球重力及降落)及粒子系統(噴射) 世界地圖可根據視角縮放 困難點: 重寫3次最終改寫成物件導向的CLASS寫法...