tween
This commit is contained in:
parent
ea6c8417aa
commit
e129ad150f
|
@ -124,6 +124,7 @@ var Window = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var Color = {
|
var Color = {
|
||||||
white: [255,255,255,255],
|
white: [255,255,255,255],
|
||||||
blue: [84,110,255,255],
|
blue: [84,110,255,255],
|
||||||
|
@ -311,7 +312,14 @@ var timer = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var t = clone(this);
|
var t = clone(this);
|
||||||
t.id = make_timer(this.guardfn.bind(t,fn), secs, obj);
|
t.callback = fn;
|
||||||
|
var guardfn = function() {
|
||||||
|
if (typeof t.callback === 'function')
|
||||||
|
t.callback();
|
||||||
|
else
|
||||||
|
Log.warn("Timer trying to execute without a function.");
|
||||||
|
};
|
||||||
|
t.id = make_timer(guardfn, secs, obj);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
},
|
},
|
||||||
|
@ -336,8 +344,40 @@ var timer = {
|
||||||
kill() { cmd(27, this.id); },
|
kill() { cmd(27, this.id); },
|
||||||
set time(x) { cmd(28, this.id, x); },
|
set time(x) { cmd(28, this.id, x); },
|
||||||
get time() { return cmd(29, this.id); },
|
get time() { return cmd(29, this.id); },
|
||||||
|
get pct() { return this.remain / this.time; },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var Tween = {
|
||||||
|
default: {
|
||||||
|
ease: "inout", /* easing at end and beginning of tween */
|
||||||
|
loop: "restart", /* none, restart, yoyo, increment */
|
||||||
|
time: 1, /* seconds to do */
|
||||||
|
},
|
||||||
|
|
||||||
|
start(target, start, end, options)
|
||||||
|
{
|
||||||
|
var defn = Object.create(this.default);
|
||||||
|
Object.apply(defn, options);
|
||||||
|
|
||||||
|
var newtimer = timer.make(null, defn.time, null, true);
|
||||||
|
newtimer.pause();
|
||||||
|
|
||||||
|
var tween_fn = function() {
|
||||||
|
Log.warn(newtimer.pct);
|
||||||
|
};
|
||||||
|
timer.callback = tween_fn;
|
||||||
|
timer.callback();
|
||||||
|
timer.start();
|
||||||
|
},
|
||||||
|
|
||||||
|
lerp(s, e, t)
|
||||||
|
{
|
||||||
|
t = Math.clamp(t,0,1);
|
||||||
|
return ((e - s) * t) + s;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var animation = {
|
var animation = {
|
||||||
time: 0,
|
time: 0,
|
||||||
loop: false,
|
loop: false,
|
||||||
|
|
|
@ -32,6 +32,6 @@ uv9slice(vec2 uv, vec2 s, vec4 b)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
uv = uv9slice(uv, scale, border);
|
vec2 nuv = uv9slice(uv, scale, border);
|
||||||
color = fcolor * texture(image, uv);
|
color = fcolor * texture(image, uv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
layout (location = 0) in vec2 vert;
|
layout (location = 0) in vec2 vert;
|
||||||
layout (location = 1) in vec2 uv;
|
layout (location = 1) in vec2 vuv;
|
||||||
layout (location = 2) in vec4 vborder;
|
layout (location = 2) in vec4 vborder;
|
||||||
layout (location = 3) in vec2 vscale;
|
layout (location = 3) in vec2 vscale;
|
||||||
layout (location = 4) in vec4 vcolor;
|
layout (location = 4) in vec4 vcolor;
|
||||||
|
@ -17,7 +17,7 @@ void main()
|
||||||
{
|
{
|
||||||
gl_Position = projection * vec4(vert, 0.0, 1.0);
|
gl_Position = projection * vec4(vert, 0.0, 1.0);
|
||||||
|
|
||||||
uv = vert;
|
uv = vuv;
|
||||||
border = vborder;
|
border = vborder;
|
||||||
scale = vscale;
|
scale = vscale;
|
||||||
fcolor = vcolor;
|
fcolor = vcolor;
|
||||||
|
|
Loading…
Reference in a new issue