Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compass Dependancy #1

Open
DarbyBrown opened this issue Aug 7, 2013 · 0 comments
Open

Compass Dependancy #1

DarbyBrown opened this issue Aug 7, 2013 · 0 comments

Comments

@DarbyBrown
Copy link
Owner

It was brought to my attention that sin and cos are functions of Compass not Sass.
So if you don't use Compass here is a an alternative function for sin and cos.
I haven't tested it yet but will report back when I do.

Created by Jelmer Borst - https://twitter.com/japborst

$pi: 3.14159265359;

@function pow($base,$exp){
    $value: $base;
    @if $exp > 1{
        @for $i from 2 through $exp{
            $value: $value * $base;
        }
    }
    @if $exp < 1{
        @for $i from 0 through -$exp{
            $value: $value / $base;
        }
    }
    @return $value;
}
@function fact($val){
    $value: 1;
    @if $val > 0{
        @for $i from 1 through $number{
            $value: $value * $i;
        }
    }
}

@function sin($angle, $degrees: false){
    $sin: 0
    @if $degrees{
        $degrees: $degrees / 180 * $pi;
    }
    @for $n from 1 through 10{
        $sin: $sin + ( pow(-1,n) / fact(2n+1) ) * pow($angle,(2n+1));
    }
    @return $sin;
}
@function cos($angle, $degrees: false){
    $cos: 0
    @if $degrees{
        $degrees: $degrees / 180 * $pi;
    }
    @for $n from 1 through 10{
        $cos: $cos + ( pow(-1,n) / fact(2n) ) * pow($angle,2n);
    }
    @return $cos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant