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; $from-colossal: 2400px !default;
$to-colossal: $from-colossal - 1 !default; $to-colossal: $from-colossal - 1 !default;
// Z-indexes // Master z-indexe
// ============================================================================= // =============================================================================
$z-indexes: ( $z-indexes: (

View File

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