// Public functions that can be used globally.
@import "dependencies"; // Don't remove me

// addresses https://github.com/nex3/sass/issues/533
// number strip-units ( number $number )
@function strip-units($number) {
  @return $number / ($number * 0 + 1);
}

// to determine the unit. If it's a percentage, then our equation changes.
// number em ( number $px, [ number $base: $base-font-size ] )
@function em($px, $base: $base-font-size) {
  @return _calcRU($px, $base, "em");
}

// number rem ( number $px, [ number $base: $base-font-size ] )
@function rem($px, $base: $base-font-size) {
  @return _calcRU($px, $base, "rem");
}

// number percent ( number $px, [ number $base: $base-font-size ] )
@function percent($px, $base: $base-font-size) {
  @return _calcRU($px, $base, "%");
}

// number relative ( number $size )
@function relative($size) {
  @if ($use-rem == true and $use-em == false and $use-percent == false) {
    @return rem($size);
  } @else if ($use-em == true and $use-rem == false and $use-percent == false) {
    @return em($size);
  } @else if ($use-percent == true and $use-rem == false and $use-em == false) {
    @return percent($size);
  }

  @return $size; // we're still using pixels
}

// list triad ( color $color )
@function triad($color) {
  @if (type-of($color) != "color") {
    @warn "Type must be color to continue. Aborting.";
    @return null;
  }

  $triad: ();
  $hue: strip-units(hue($color));

  @for $i from 1 through 3 {
    @if ($hue + 120 > 360) {
      $hue: ($hue + 120) - 360;
    } @else {
      $hue: $hue + 120;
    }
    $color: hsl($hue, saturation($color), lightness($color));
    $triad: append($triad, $color);
  }

  @return $triad;
}

// list square ( color $color )
@function square($color) {
  @if (type-of($color) != "color") {
    @warn "Type must be color to continue. Aborting.";
    @return null;
  }

  $square: ();
  $hue: strip-units(hue($color));

  @for $i from 1 through 4 {
    @if ($hue + 90 > 360) {
      $hue: ($hue + 90) - 360;
    } @else {
      $hue: $hue + 90;
    }
    $color: hsl($hue, saturation($color), lightness($color));
    $square: append($square, $color);
  }

  @return $square;
}
