@mixin scut-triangle (
  $direction: right,
  $size: 0.75em,
  $color: inherit
) {

  display: inline-block;
  height: 0;
  width: 0;
  // For improved appearance in some Webkit browsers
  -webkit-transform: rotate(360deg);

  // Set up some variables
  $width: null;
  $height: null;
  $border-widths: null;

  @if type-of($size) == list {
    $width: nth($size, 1);
    $height: nth($size, 2);
  }
  @else {
    $width: $size;
    $height: $size;
  }

  @if ($direction == up) or ($direction == down) {
    // For up and down, width gets two borders but height only one,
    // so divide second border-width value by 2
    $border-widths: $height ($width * 0.5);
  }
  @else if ($direction == right) or ($direction == left) {
    // For right and left, height gets two borders but width only one,
    // so divide first border-width value by 2
    $border-widths: ($height * 0.5) $width;
  }
  @else {
    // For right triangles (the rest), both sides get two borders,
    // so divide both by 2
    $border-widths: ($height * 0.5) ($width * 0.5);
  }

  border-width: $border-widths;
  border-style: solid;


  // STANDARD TRIANGLES

  @if ($direction == up) or ($direction == down) or ($direction == right) or ($direction == left) {
    border-color: transparent;
    @if $direction == up {
      border-bottom-color: $color;
      border-top-width: 0;
    }
    @else if $direction == right {
      border-left-color: $color;
      border-right-width: 0;
    }
    @else if $direction == down {
      border-top-color: $color;
      border-bottom-width: 0;
    }
    @else if $direction == left {
      border-right-color: $color;
      border-left-width: 0;
    }
  }


  // CORNER TRIANGLES

  @else if ($direction == top-right) or ($direction == top-left) {
    border-top-color: $color;
    border-bottom-color: transparent;
    @if $direction == top-right {
      border-left-color: transparent;
      border-right-color: $color;
    }
    @else if $direction == top-left {
      border-left-color: $color;
      border-right-color: transparent;
    }
  }

  @else if ($direction == bottom-right) or ($direction == bottom-left) {
    border-top-color: transparent;
    border-bottom-color: $color;
    @if $direction == bottom-right {
      border-left-color: transparent;
      border-right-color: $color;
    }
    @else if $direction == bottom-left {
      border-left-color: $color;
      border-right-color: transparent;
    }
  }

}

%scut-triangle {
  @include scut-triangle;
}