Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.