January 28, 2014♦
☀
E
F
F
L
U
E
N
C
E
☀
EVR.Animation.Ending.Corpse.Soul = function(corpse)
{
EVR.Graphic.call(this, corpse.container, RATIO_WIDTH, null, ALIGN_CENTER);
EVR.Animation.call(this, SOUL_FRAME_RATE);
this.corpse = corpse;
this.colors = TRANSMISSION_COLORS;
this.color_index = 0;
this.update_meter = 0;
this.growth_finished = false;
this.set_attributes();
}
EVR.Animation.Ending.Corpse.Soul.prototype = new EVR.Graphic;
EVR.inherit(EVR.Animation.Ending.Corpse.Soul, EVR.Animation);
EVR.Animation.Ending.Corpse.Soul.prototype.set_attributes = function()
{
this.set_z(SOUL_Z_INDEX);
this.set_proportions(0, SOUL_HEIGHT);
}
EVR.Animation.Ending.Corpse.Soul.prototype.sequence = function()
{
this.advance_color_index();
this.set_color(this.colors[this.color_index]);
var dimensions = this.get_dimensions(true);
var width = dimensions[0] || .005;
if (width < 1 || dimensions[1] < 1)
{
var growth_factor = width * SOUL_ZOOM_STEP;
this.grow(growth_factor);
}
else if (!this.growth_finished)
{
var current = this;
var ending = this.corpse.ending;
window.setTimeout(
function()
{
ending.reset();
ending.draw();
ending.display_message();
ending.finished = true;
current.stop();
}, ENDING_MESSAGE_DELAY);
this.growth_finished = true;
}
}
EVR.Animation.Ending.Corpse.Soul.prototype.advance_color_index = function()
{
this.advance_update_meter();
if (this.update_meter == 0)
{
var index = this.color_index;
if (++index >= this.colors.length)
{
index = 0;
}
this.color_index = index;
}
}
EVR.Animation.Ending.Corpse.Soul.prototype.advance_update_meter = function()
{
var meter = this.update_meter;
if (++meter >= SOUL_UPDATE_METER_LIMIT)
{
meter = 0;
}
this.update_meter = meter;
}
EVR.Animation.Ending.Corpse.Soul.prototype.reset = function()
{
this.growth_finished = false;
this.set_proportions(0, SOUL_HEIGHT);
}
EVR.Animation.Ending.Corpse.Soul.prototype.toString = function()
{
return "[object EVR.Animation.Ending.Corpse.Soul]";
}
EVR.include("animation/ending/rainbow/Band.js");
EVR.Animation.Ending.Rainbow = function(ending)
{
EVR.Animation.call(this, RAINBOW_FRAME_RATE);
this.ending = ending;
this.container = ending.container;
this.tombstone = ending.tombstone;
this.set_width();
this.add_bands();
}
EVR.Animation.Ending.Rainbow.prototype = new EVR.Animation;
EVR.Animation.Ending.Rainbow.prototype.set_width = function()
{
var container_dimensions = this.container.get_dimensions();
this.width = (
container_dimensions[1] * TOMBSTONE_HEIGHT * TOMBSTONE_WIDTH) /
container_dimensions[0];
}
EVR.Animation.Ending.Rainbow.prototype.add_bands = function()
{
var colors = TRANSMISSION_COLORS;
var bands = []
for (var ii = 0; ii < colors.length; ii++)
{
bands.push(new EVR.Animation.Ending.Rainbow.Band(this, ii));
}
this.bands = bands;
}
EVR.Animation.Ending.Rainbow.prototype.append = function()
{
this.set_width();
this.apply_to_bands("set_attributes");
this.apply_to_bands("append");
}
EVR.Animation.Ending.Rainbow.prototype.apply_to_bands = function(method)
{
var band, bands = this.bands;
var args = Array.prototype.slice.call(arguments);
for (var ii = 0; ii < bands.length; ii++)
{
band = bands[ii];
band[method].apply(band, args.slice(1));
}
}
EVR.Animation.Ending.Rainbow.prototype.sequence = function()
{
this.apply_to_bands("grow", null, RAINBOW_STEP);
var height = this.bands[0].get_dimensions(true)[1];
if (height > 1)
{
var ending = this.ending;
var family = ending.family;
var delay = CORPSE_DELAY;
this.stop();
ending.corpse.play(null, delay);
family.stop();
family.play("jump", delay + FAMILY_JUMP_DELAY);
}
}
EVR.Animation.Ending.Rainbow.prototype.draw = function()
{
this.apply_to_bands("draw");
}
EVR.Animation.Ending.Rainbow.prototype.reset = function()
{
this.apply_to_bands("set_proportions", null, 0);
}
EVR.Animation.Ending.Rainbow.prototype.remove = function()
{
this.apply_to_bands("remove");
}
EVR.Animation.Ending.Rainbow.prototype.toString = function()
{
return "[object EVR.Animation.Ending.Rainbow]";
}
EVR.Animation.Ending.Rainbow.Band = function(rainbow, index)
{
EVR.Graphic.call(
this, rainbow.container, null, rainbow.tombstone, ALIGN_BOTTOM_LEFT);
this.rainbow = rainbow;
this.index = index;
this.palette = TRANSMISSION_COLORS;
this.set_attributes();
}
EVR.Animation.Ending.Rainbow.Band.prototype = new EVR.Graphic;
EVR.Animation.Ending.Rainbow.Band.prototype.set_attributes = function()
{
var palette = this.palette;
var color = palette[this.index];
var count = palette.length;
var width = this.rainbow.width / count;
var offset = this.index * width;
this.set_color(color);
this.set_proportions(width, 0);
this.set_z(RAINBOW_Z_INDEX);
this.set_opacity(RAINBOW_OPACITY);
this.place(offset, .01);
}
EVR.Animation.Ending.Rainbow.Band.prototype.toString = function()
{
return "[object EVR.Animation.Ending.Rainbow.Band]";
}
EVR.Animation.Fader = function(component, end, rate, length, repeat)
{
EVR.Animation.call(this, rate);
this.component = component;
this.length = length;
this.repeat = repeat || false;
this.elapsed = 0;
this.set_path(end)
}
EVR.Animation.Fader.prototype = new EVR.Animation;
EVR.Animation.Fader.prototype.set_path = function(end)
{
this.elapsed = 0;
this.set_range(end);
this.set_deltas();
}
EVR.Animation.Fader.prototype.set_range = function(end)
{
var start = new EVR.Color(this.component.get_color());
this.current = new EVR.Color(this.component.get_color());
if (typeof end == "string")
{
end = new EVR.Color(end);
}
this.range = [start, end];
}
EVR.Animation.Fader.prototype.set_deltas = function()
{
var start = this.range[0];
var end = this.range[1];
this.deltas = [];
this.deltas.push(this.calculate_delta(start.rgb[0], end.rgb[0]));
this.deltas.push(this.calculate_delta(start.rgb[1], end.rgb[1]));
this.deltas.push(this.calculate_delta(start.rgb[2], end.rgb[2]));
}
EVR.Animation.Fader.prototype.calculate_delta = function(start, end)
{
return (end - start) / (this.length / this.rate);
}
EVR.Animation.Fader.prototype.sequence = function()
{
this.current.rgb[0] += this.deltas[0];
this.current.rgb[1] += this.deltas[1];
this.current.rgb[2] += this.deltas[2];
this.component.set_color(this.current.get_string());
this.elapsed += this.rate;
if (this.elapsed >= this.length)
{
this.component.set_color(this.range[1].get_string());
if (this.repeat)
{
this.set_path(this.range[0]);
}
else
{
this.stop();
}
}
}
EVR.Animation.Fader.prototype.toString = function()
{
return "[object EVR.Animation.Fader]";
}