MathSass
A Sass implementation of mathematical functions.
Install
Git
git clone git@github.com:terkel/mathsass.git && cd mathsass
Bower
bower install mathsass --save-dev
npm
npm install mathsass --save-dev
Usage
Import dist/_math.scss
partial to the Sass document.
@import "path/to/dist/math";
.content {
height: 200px;
width: 200px / tan(60deg);
}
If you installed via Npm the path will be: node_modules/mathsass/dist/math
If you installed via Bower the path will be: bower_components/mathsass/dist/math
Features
Constants
$E
- Euler's constant (ネイピア数 [オイラー数])$PI
- π (円周率)$LN2
- The natural logarithm of 2 (2 の自然対数)$SQRT2
- The square root of 2 (2 の平方根)
Functions
Exponentiation
@debug pow(4, 2);
@debug pow(4, -2);
@debug pow(4, 0.2);
Factorial
@debug fact(4);
@debug fact(8);
Square root
@debug sqrt(2);
@debug sqrt(3);
Exponential function
exp($x)
frexp($x)
ldexp($x, $exp)
@debug exp(-1);
@debug exp(0);
@debug exp(1);
Logarithms
@debug log(2);
@debug log(10);
@debug log(2, 10);
Trigonometric functions
sin($x)
- Sine (正弦)cos($x)
- Cosine (余弦)tan($x)
- Tangent (正接)csc($x)
- Cosecant (余割)sec($x)
- Secant (正割)cot($x)
- Cotangent (余接)
If argument has deg
unit, converted to rad
.
@debug tan(0.5236);
@debug tan(30deg);
Inverse trigonometric functions
asin($x)
- Arcsine (逆正弦)acos($x)
- Arccosine (逆余弦)atan($x)
- Arctangent (逆正接)atan2($y, $x)
- Arctangent of the quotient of its arguments (引数の比率での逆正接)
@debug atan2(0, 0);
@debug atan2(0, -0.0);
@debug atan2(-0.0, 0);
@debug atan2(-0.0, -0.0);
Helper functions
strip-unit($number)
deg-to-rad($deg, $unit: true)
rad-to-deg($rad, $unit: true)
unitless-rad($angle)
@debug rad-to-deg(1.0472);
@debug deg-to-rad(60deg);
@debug deg-to-rad(60deg, false);
@debug unitless-rad(60deg);
@debug unitless-rad(1.0472rad);
References
…and Wikipedia articles:
Contributing
Make sure you have node.js and grunt installed.
Clone Repository
git clone git@github.com:terkel/mathsass.git
Install Dependencies
npm install
Run Sass/Tests
grunt
Credits
Originally created with help from @kaminaly and @pilssalgi.
License
Copyright (c) 2013 Takeru Suzuki
Licensed under the MIT license.