-
Notifications
You must be signed in to change notification settings - Fork 3
/
Animation.hx
75 lines (65 loc) · 2.41 KB
/
Animation.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* hxGD.Animation.hx
*
* Copyright 2010 Philipp Klose <me@thehippo.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package hxGD;
import neko.Lib;
class Animation {
private var filename:String;
private var delay:Int;
private var loop:Bool;
private var optimise:Bool;
private var globalCM:Bool;
private var data:Void;
/**
* creates a new Animation
* @param filename where to save the gif animation
* @param delay delay between each frame in milliseconds
* @param loop
* @param optimise optimise output works only with a global color map
* @param globalCM using a global colormap, smaller files, slower creationtime
*/
public function new(filename:String,delay:Int,?loop:Bool=true,?optimise:Bool=true,globalCM:Bool=true) {
data = gd_initAnim();
this.filename = filename;
this.delay = delay;
this.loop = loop;
this.optimise = optimise;
this.globalCM = globalCM;
}
/**
* adds an image to the animation. a copy of the image is made so can alter it of throw it
* @param image
*/
public function addImage(image:Image):Void {
gd_addImage(data,image.img);
}
/**
* finally render the animation to the file
*/
public function render():Void {
gd_renderGifAnimation(data,loop,Lib.haxeToNeko(filename),globalCM,delay,optimise);
}
private static var gd_renderGifAnimation = Lib.load("nGD","RenderGifAnimation",-1);
private static var gd_initAnim = Lib.load("nGD","InitAnimation",0);
private static var gd_addImage = Lib.load("nGD","AddImage",2);
//value InitAnimation();
//value AddImage(value list,value image);
//value RenderGifAnimation(value images,value loop,value filename,value globalCM,value delay,value optimise) {
}