1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Update scss maths comments

This commit is contained in:
Lucas Vallenet
2022-05-25 13:57:30 +02:00
parent 34bca7d68a
commit d7de1b2566
2 changed files with 27 additions and 16 deletions

View File

@@ -90,7 +90,7 @@ $to-gigantic: $from-gigantic - 1 !default;
$from-colossal: 2400px !default;
$to-colossal: $from-colossal - 1 !default;
// Z-indexes
// Master z-indexe
// =============================================================================
$z-indexes: (

View File

@@ -2,8 +2,9 @@
// Tools / Maths
// ==========================================================================
// Remove units from the given number
// @param {number} $number The number with units
// Removes the unit from the given number.
//
// @param {number} $number The number to strip.
// @return {number}
@function strip-units($number) {
@@ -18,10 +19,12 @@
@function sqrt($number) {
$x: 1;
$value: $x;
@for $i from 1 through 10 {
$value: $x - ($x * $x - abs($number)) / (2 * $x);
$x: $value;
$value: $x - ($x * $x - abs($number)) / (2 * $x);
$x: $value;
}
@return $value;
}
@@ -33,6 +36,7 @@
@function pow($number, $exp) {
$value: 1;
@if $exp > 0 {
@for $i from 1 through $exp {
$value: $value * $number;
@@ -42,6 +46,7 @@
$value: $value / $number;
}
}
@return $value;
}
@@ -52,11 +57,13 @@
@function fact($number) {
$value: 1;
@if $number > 0 {
@for $i from 1 through $number {
$value: $value * $i;
}
}
@return $value;
}
@@ -76,47 +83,51 @@
@function rad($angle) {
$unit: unit($angle);
$unitless: $angle / ($angle * 0 + 1);
// If the angle has 'deg' as unit, convert to radians.
@if $unit == deg {
$unitless: $unitless / 180 * pi();
}
@return $unitless;
}
// Calculate the sinus of an angle
// Returns the sine of the given number.
//
// @param {string} $angle The angle to compute
// @return {number} The sinus of the given angle
// @param {number} $angle The angle to calculate.
// @return {number}
@function sin($angle) {
$sin: 0;
$angle: rad($angle);
// Iterate a bunch of times.
@for $i from 0 through 10 {
$sin: $sin + pow(-1, $i) * pow($angle, (2 * $i + 1)) / fact(2 * $i + 1);
}
@return $sin;
}
// Calculate the cosinus of an angle
// Returns the cosine of the given number.
//
// @param {string} $angle The angle to compute
// @return {number} The cosinus of the given angle
// @param {string} $angle The angle to calculate.
// @return {number}
@function cos($angle) {
$cos: 0;
$angle: rad($angle);
// Iterate a bunch of times.
@for $i from 0 through 10 {
$cos: $cos + pow(-1, $i) * pow($angle, 2 * $i) / fact(2 * $i);
}
@return $cos;
}
// Calculate the tangent of an angle
// Returns the tangent of the given number.
//
// @param {string} $angle The angle to compute
// @return {number} The tangent of the given angle
// @param {string} $angle The angle to calculate.
// @return {number}
@function tan($angle) {
@return sin($angle) / cos($angle);