Skip to content

Instantly share code, notes, and snippets.

@magicspon
Created April 26, 2015 20:48
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 magicspon/3162d1536dc0c692e427 to your computer and use it in GitHub Desktop.
Save magicspon/3162d1536dc0c692e427 to your computer and use it in GitHub Desktop.
Box Shadow functions
<div class="test"></div>
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
@function circle($points: 50,$r: 20,$x: 10,$y: 10) {
$output: '';
@for $i from 1 through $points {
$x: $x + $r * sin(2 * pi() * $i / $points);
$y: $y + $r * cos(2 * pi() * $i / $points);
$output: $output + ' ' + ($x * 1px) + ' ' + ($y * 1px) + ' 0 0 #1a1a1a';
@if $i < $points {
$output: $output + ',';
}
}
@return unquote($output);
}
$colors: #502B80 #247966 #5AFEA6 #9061C2 #97B9AE #502B80 #247966 #5AFEA6 #9061C2 #97B9AE;
// credit: http://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/
@function reverse($list, $recursive: false) {
$result: ();
@for $i from length($list)*-1 through -1 {
@if type-of(nth($list, abs($i))) == list and $recursive {
$result: append($result, reverse(nth($list, abs($i)), $recursive));
}
@else {
$result: append($result, nth($list, abs($i)));
}
}
@return $result;
}
@function loop($list, $value: 1) {
$result: ();
@for $i from 0 to length($list) {
$result: append($result, nth($list, ($i - $value) % length($list) + 1));
}
@return $result;
}
// end of
@function line($angle: 0deg, $points: 10, $distance: 250, $size: 2px, $color: green, $growth: 1.2, $offset: 0, $blur: 5px){
$output:'';
$x: null;
$y: null;
$segment: ($distance / $points);
$pulse: ();
$half: ceil($points / 2);
@for $i from 1 through $half {
$pulse: append($pulse,$i * $growth);
}
$rev: reverse($pulse, $recursive: true);
$pulse: join($pulse,$rev);
$pulse: loop($pulse,$offset);
@for $i from 1 through $points {
$x: (($segment * sin($angle)) * $i) * 1px;
$y: (($segment * cos($angle)) * $i) * 1px;
$output: $output + $x + ' ' + $y + ' ' + $blur + ' ' + (nth($pulse,$i) * 1px) + ' ' + adjust-color($color, $hue: ($segment * cos($angle) * $i));
// add trailing commo to all by the last iteration
@if $i < $points {
$output: $output + ',';
}
}
@return unquote($output);
}
@function line-loop($count: 10, $points: 10, $distance: 250, $size: 2px, $color: green, $growth: 1.2, $offset: 0, $blur: 0) {
$k: 360 / $count;
$output: '';
@for $i from 1 through $count {
$output: $output + line($angle: ($k * $i) * 1deg, $points: $points, $distance: $distance, $size: $size, $color: $color, $growth: $growth, $offset: $offset, $blur: $blur);
@if $i < $count {
$output: $output + ',';
}
}
@return unquote($output);
}
<div class="test"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment