?
@function pi(){
@return 3.141592653589793;
}
@function pow ($x, $n) {
$ret: 1;
@if $n >= 0 {
@for $i from 1 through $n {
$ret: $ret * $x;
}
} @else {
@for $i from $n to 0 {
$ret: $ret / $x;
}
}
@return $ret;
}
@function factorial ($x) {
$ret: 1;
@if $x > 0 {
@while $x > 0 {
$ret: $ret * $x;
$x: $x - 1;
}
} @else {
$ret: 1;
}
@return $ret;
}
@function sin ($x) {
$ret: 0;
@for $n from 0 to 25 {
$ret: $ret + pow(-1, $n) * pow($x, 2 * $n + 1) / factorial(2 * $n + 1);
}
@return $ret;
}
@function cos ($x) {
$ret: 0;
@for $n from 0 to 25 {
$ret: $ret + pow(-1, $n) * pow($x, 2 * $n) / factorial(2 * $n);
}
@return $ret;
}
@function exp ($x) {
$ret: 0;
@for $n from 0 to 25 {
$ret: $ret + pow($x, $n) / factorial($n);
}
@return $ret;
}
@function ln($x) {
$ret: 0;
$n: 1;
$dx: .001;
@while $n <= $x {
$ret: $ret + $dx / $n;
$n: $n + $dx;
}
@return $ret;
}
@function sqrt($x) {
@return exp(0.5 * ln($x));
}
@function shadow($blur:3px, $alpha:.5, $x:0, $y:0, $color:black) {
$col_base : rgba($color,1);
$col_alpha : alpha($color);
$alpha_tot : $alpha * $col_alpha;
$shadows: false;
@while ( $alpha_tot > 0 ) {
$shadow: $x $y $blur rgba($col_base, min($alpha_tot , 1));
@if ($shadows ){
$shadows : $shadow , $shadows;
} @else {
$shadows : $shadow;
}
$alpha_tot : $alpha_tot - 1;
}
@return $shadows;
}