/*
Stylus variables are information about icon's compiled state, stored under its original file name

.icon-home {
  width: $icon_home_width;
}

The large array-like variables contain all information about a single icon
$icon_home = x y offset_x offset_y width height total_width total_height image_path;

At the bottom of this section, we provide information about the spritesheet itself
$spritesheet = width height image $spritesheet_sprites;
*/
$fork_name = 'fork';
$fork_x = 0px;
$fork_y = 0px;
$fork_offset_x = 0px;
$fork_offset_y = 0px;
$fork_width = 32px;
$fork_height = 32px;
$fork_total_width = 84px;
$fork_total_height = 84px;
$fork_image = 'spritesheet.padding.png';
$fork = 0px 0px 0px 0px 32px 32px 84px 84px 'spritesheet.padding.png' 'fork';
$github_name = 'github';
$github_x = 52px;
$github_y = 0px;
$github_offset_x = -52px;
$github_offset_y = 0px;
$github_width = 32px;
$github_height = 32px;
$github_total_width = 84px;
$github_total_height = 84px;
$github_image = 'spritesheet.padding.png';
$github = 52px 0px -52px 0px 32px 32px 84px 84px 'spritesheet.padding.png' 'github';
$twitter_name = 'twitter';
$twitter_x = 0px;
$twitter_y = 52px;
$twitter_offset_x = 0px;
$twitter_offset_y = -52px;
$twitter_width = 32px;
$twitter_height = 32px;
$twitter_total_width = 84px;
$twitter_total_height = 84px;
$twitter_image = 'spritesheet.padding.png';
$twitter = 0px 52px 0px -52px 32px 32px 84px 84px 'spritesheet.padding.png' 'twitter';
$spritesheet_width = 84px;
$spritesheet_height = 84px;
$spritesheet_image = 'spritesheet.padding.png';
$spritesheet_sprites = $fork $github $twitter;
$spritesheet = 84px 84px 'spritesheet.padding.png' $spritesheet_sprites;

/*
The provided mixins are intended to be used with the array-like variables

.icon-home {
  spriteWidth($icon_home)
}

.icon-email {
  sprite($icon_email)
}
*/
spriteWidth($sprite) {
  width: $sprite[4];
}

spriteHeight($sprite) {
  height: $sprite[5];
}

spritePosition($sprite) {
  background-position: $sprite[2] $sprite[3];
}

spriteImage($sprite) {
  background-image: url($sprite[8]);
}

sprite($sprite) {
  spriteImage($sprite)
  spritePosition($sprite)
  spriteWidth($sprite)
  spriteHeight($sprite)
}

/*
The `sprites` mixin generates identical output to the CSS template
  but can be overridden inside of Stylus

This must be run when you have at least 2 sprites.
  If run with a single sprite, then there will be reference errors.

sprites($spritesheet_sprites);
*/
sprites($sprites) {
  for $sprite in $sprites {
    $sprite_name = $sprite[9];
    .{$sprite_name} {
      sprite($sprite);
    }
  }
}
