Skip to content

Instantly share code, notes, and snippets.

@GreenGremlin
Created January 29, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GreenGremlin/416e4b4ed094609a4440 to your computer and use it in GitHub Desktop.
Save GreenGremlin/416e4b4ed094609a4440 to your computer and use it in GitHub Desktop.
Sass matrix rotation (doesn't quite work)
// Matrix rotation version:
// this would work, except the y-axis is fliped for box-shadow
$m-0-degrees: ((1, 0), (0, 1));
$m-90-degrees: ((0, 1), (-1, 0));
$m-180-degrees: ((-1, 0), (0, -1));
$m-270-degrees: ((0, -1), (1, 0));
@function m-rotate($x, $y, $m) {
$m1: nth($m, 1);
$m2: nth($m, 2);
@return nth($m1, 1)*$x+nth($m1, 2)*$x nth($m2, 1)*$y+nth($m2, 2)*$y;
}
@mixin shadow-dots($mx, $color1, $color2, $size) {
box-shadow:
m-rotate(15px, 15px, $mx) red,
m-rotate(15px, -15px, $mx) blue,
m-rotate(-15px, -15px, $mx) green,
m-rotate(-15px, 15px, $mx) yellow;
}
@mixin shadow-dots($x, $y, $x2, $y2, $color1, $color2, $size) {
box-shadow:
($size*$x)+($size*$x2) ($size*$y)+($size*$y2) $color2,
($size*$x)+($size*$x2) ($size*$y*-1)+($size*$y2*-1) $color1,
($size*$x*-1)+($size*$x2*-1) ($size*$y*-1)+($size*$y2*-1) $color2,
($size*$x*-1)+($size*$x2*-1) ($size*$y)+($size*$y2) $color1;
}
@keyframes spin {
0%, 100% {
@include shadow-dots($m-0-degrees, $spinnerColor, $spinnerColor2, $spinnerSize);
}
25% {
@include shadow-dots($m-90-degrees, $spinnerColor2, $spinnerColor, $spinnerSize);
}
50% {
@include shadow-dots($m-180-degrees, $spinnerColor, $spinnerColor2, $spinnerSize);
}
75% {
@include shadow-dots($m-270-degrees, $spinnerColor2, $spinnerColor, $spinnerSize);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment