EVR.include("account/form/input/Background.js");
EVR.Account.Form.Input = function(form, initial_value, type)
{
   this.form = form;
   this.initial_value = initial_value;
   this.type = type;
   this.build_container();
   this.initialize();
   this.background = new EVR.Account.Form.Input.Background(this);
   this.swap();
}
EVR.Account.Form.Input.prototype.build_container = function()
{
   this.container = document.createElement("div");
}
EVR.Account.Form.Input.prototype.initialize = function()
{
   var element = document.createElement("input");
   element.type = this.type;
   element.style.color = FORM_FOCUSED_TEXT_COLOR;
   this.container.appendChild(element);
   this.element = element;
   this.add_blur_listener();
   this.add_focus_listener();
}
EVR.Account.Form.Input.prototype.add_blur_listener = function()
{
   var current = this;
   this.element.onblur = 
      function() {
	 if (current.get_value() == "")
	 {
	    current.swap();
	 }
      };
}
EVR.Account.Form.Input.prototype.add_focus_listener = function()
{
   var current = this;
   this.element.onfocus =
      function() {
	 current.select()
      };
}
EVR.Account.Form.Input.prototype.swap = function()
{
   this.hide();
   this.background.show();
}
EVR.Account.Form.Input.prototype.hide = function()
{
   this.element.style.display = "none";
}
EVR.Account.Form.Input.prototype.show = function()
{
   this.element.style.display = "block";
}
EVR.Account.Form.Input.prototype.set_value = function(value)
{
   this.element.value = value;
}
EVR.Account.Form.Input.prototype.get_value = function()
{
   return this.element.value;
}
EVR.Account.Form.Input.prototype.select = function()
{
   var element = this.element;
   if (element.style.display == "none")
   {
      this.background.swap();
   }
   element.select();
}
EVR.Account.Form.Input.prototype.set_background = function(color)
{
   this.element.style.background = color;
   this.background.element.style.background = color;
}
EVR.Account.Form.Input.prototype.append = function()
{
   this.form.element.appendChild(this.container);
}
EVR.Account.Form.Input.Background = function(foreground)
{
   this.foreground = foreground;
   this.initialize();
}
EVR.Account.Form.Input.Background.prototype.initialize = function()
{
   var foreground = this.foreground;
   var element = document.createElement("input");
   element.type = "text";
   element.style.color = FORM_UNFOCUSED_TEXT_COLOR;
   element.value = foreground.initial_value;
   foreground.container.appendChild(element);
   this.element = element;
   this.add_focus_listener();
}
EVR.Account.Form.Input.Background.prototype.add_focus_listener = function()
{
   var current = this;
   this.element.onfocus = 
      function() {
	 current.swap();
      };
}
EVR.Account.Form.Input.Background.prototype.swap = function()
{
   var foreground = this.foreground;
   this.hide();
   foreground.show();
   window.setTimeout(function() { foreground.element.focus() }, 50);
}
EVR.Account.Form.Input.Background.prototype.hide = function()
{
   this.element.style.display = "none";
}
EVR.Account.Form.Input.Background.prototype.show = function()
{
   this.element.style.display = "block";
}
EVR.About = function(evr)
{
   EVR.Pop_Up.call(this, evr.field, ABOUT_WIDTH, ABOUT_HEIGHT);
   this.palette = ABOUT_PALETTE;
   this.include_document();
}
EVR.About.prototype = new EVR.Pop_Up;
EVR.About.prototype.set_attributes = function()
{
   EVR.Pop_Up.prototype.set_attributes.call(this);
   this.set_color(ABOUT_BACKGROUND);
   var css = this.css;
   css.textAlign = ABOUT_TEXT_ALIGN;
   css.fontSize = ABOUT_FONT_SIZE;
   css.fontFamily = ABOUT_FONT_FAMILY;
   css.color = ABOUT_FONT_COLOR;
   css.padding = ABOUT_PADDING;
}
EVR.About.prototype.include_document = function()
{
   var path = SOURCE_PATH + "about/about";
   var document = new EVR.Requester(path, null, true).execute().split("\n\n");
   this.parse_document(document);
}
EVR.About.prototype.parse_document = function(document)
{
   var block;
   for (var ii = 0; ii < document.length; ii++)
   {
      block = document[ii];
      if (block.slice(0, 1) != ABOUT_HEADING_INDICATOR)
      {
	 this.add_paragraph(block, ii == document.length - 1);
	 continue;
      }
      this.add_credits(block, ii);
   }
}
EVR.About.prototype.add_paragraph = function(paragraph, last)
{
   var element = document.createElement("div");
   var style = element.style;
   element.innerHTML = paragraph;
   style.fontStyle = ABOUT_PARAGRAPH_FONT_STYLE;
   style.color = ABOUT_PARAGRAPH_FONT_COLOR;
   style.textAlign = ABOUT_PARAGRAPH_TEXT_ALIGN;
   style.lineHeight = ABOUT_PARAGRAPH_LINE_HEIGHT;
   style.padding = ABOUT_PARAGRAPH_PADDING;
   style.fontWeight = ABOUT_PARAGRAPH_FONT_WEIGHT;
   style.border = ABOUT_PARAGRAPH_BORDER;
   style.backgroundColor = this.palette[0];
   style.marginBottom = last ? 0 : 30;
   this.element.appendChild(element);
}
EVR.About.prototype.add_credits = function(block, index)
{
   var lines = block.split("\n");
   var color = this.palette[index];
   this.add_heading(lines.shift().match(/^= (.*) =$/)[1], color);
   for (var ii = 0; ii < lines.length; ii++)
   {
      this.add_individual(lines[ii], ii == lines.length - 1);
   }
}
EVR.About.prototype.add_heading = function(heading, color)
{
   var element = document.createElement("div");
   var style = element.style;
   element.innerHTML = heading;
   style.fontSize = ABOUT_HEADING_FONT_SIZE;
   style.fontWeight = ABOUT_HEADING_FONT_WEIGHT;
   style.textDecoration = ABOUT_HEADING_TEXT_DECORATION;
   style.backgroundColor = color;
   style.paddingLeft = ABOUT_HEADING_PADDING;
   this.element.appendChild(element);
}
EVR.About.prototype.add_individual = function(individual, last)
{
   var element = document.createElement("div");
   var pattern = /^(.*) (http:\/\/.*)$/;
   if (pattern.test(individual))
   {
      element.appendChild(this.build_link(individual.match(pattern)));
   }
   else
   {
      element.innerHTML = individual;
   }
   var style = element.style;
   style.letterSpacing = ABOUT_INDIVIDUAL_LETTER_SPACING;
   style.fontSize = ABOUT_INDIVIDUAL_FONT_SIZE;
   style.paddingLeft = ABOUT_INDIVIDUAL_PADDING;
   if (last)
   {
      style.marginBottom = ABOUT_HEADING_MARGIN;
   }
   this.element.appendChild(element);
}
EVR.About.prototype.build_link = function(components)
{
   var name = components[1];
   var url = components[2];
   var element = document.createElement("a");
   var style = element.style;
   element.href = url;
   element.innerHTML = name;
   style.textDecoration = ABOUT_LINK_TEXT_DECORATION;
   style.color = ABOUT_LINK_COLOR;
   return element;
}
EVR.About.prototype.add_name = function(name)
{
   element.innerHTML = name;
   this.element.appendChild(element);
}
EVR.About.prototype.toString = function()
{
   return "[object EVR.About]";
}
3.233.219.101
3.233.219.101
3.233.219.101
 
August 12, 2013

I've been researching tartan/plaid recently for decoration in my updated version of Ball & Cup, now called Send. I want to create the atmosphere of a sports event, so I plan on drawing tartan patterns at the vertical edges of the screen as backgrounds for areas where spectator ants generate based on player performance. I figured I would make my own patterns, but after browsing tartans available in the official register, I decided to use existing ones instead.

I made a list of the tartans that had what I thought were interesting titles and chose 30 to base the game's levels on. I sequenced them, using their titles to form a loose narrative related to the concept of sending. Here are three tartans in the sequence (levels 6, 7 and 8) generated by an algorithm I inferred by looking at examples that reads a tartan specification and draws its pattern using a simple dithering technique to blend the color stripes.


Acadia


Eve


Spice Apple

It would be wasting an opportunity if I didn't animate the tartans, so I'm thinking about animations for them. One effect I want to try is making them look like water washing over the area where the ants are spectating. I've also recorded some music for the game. Here are the loops for the game over and high scores screens.

Game Over

High Scores