Accoutrement 2.1.1

Math Functions

Use these internal math functions to adjust related numbers in your maps. The functions are prefixed, to avoid conflicts, but each can be accessed in accoutrement maps using a numer of unprefixed alias names.

@function plus()

Add two values together in accoutrement maps.

Direct access to this function is prefixed, but it is available in all accoutrement maps as 'plus', 'add', or '+'.

Parameters & Return

$num1: (string | length)

The name or length of the size you are adding to

$num2: (string | length)

The name or length of the size being added

@return (number)

The calculated results of adding $num1 and $num2

Example

scss
$sizes: (
  'text': 16px,
  'margin': 14px,
  'spacer': '#text' ('plus': '#margin'),
);

@function minus()

Subtract one value from another in accoutrement maps.

Direct access to this function is prefixed, but it is available in all accoutrement maps as 'minus', 'subtract', or '-'.

Parameters & Return

$num1: (string | length)

The name or length of the size you are subtracting from

$num2: (string | length)

The name or length of the size to subtract

@return (number)

The calculated results of subtracting $num2 from $num1

Example

scss
$sizes: (
  'text': 16px,
  'margin': 14px,
  'shim': '#text' ('minus': '#margin'),
);

@function times()

Multiplty two values in accoutrement maps.

Direct access to this function is prefixed, but it is available in all accoutrement maps as 'times', 'multiply', or '*'.

Parameters & Return

$num1: (string | length)

The name or length of the size you are multiplying

$num2: (string | length)

The name or length of the size to use as a multiple

@return (number)

The calculated results of multiplying $num1 by $num2

Example

scss
$sizes: (
  'text': 16px,
  'double': '#text' ('times': 2),
);

@function divide()

Divide two values in accoutrement maps.

Direct access to this function is prefixed, but it is available in all accoutrement maps as 'divide', or '/'.

Parameters & Return

$num1: (string | length)

The name or length of the size you are dividing

$num2: (string | length)

The name or length of the size to use as a division

@return (number)

The calculated results of dividing $num1 by $num2

Example

scss
$sizes: (
  'text': 16px,
  'half': '#text' ('divide': 2),
);

@function modulo()

Divide two values in accoutrement maps, and return the remainder.

Direct access to this function is prefixed, but it is available in all accoutrement maps as 'modulo', 'remainder', 'mod', or '%'.

Parameters & Return

$num1: (string | length)

The name or length of the size you are dividing

$num2: (string | length)

The name or length of the size to use as a division

@return (number)

The calculated results of dividing $num1 by $num2

Example

scss
$sizes: (
  'text': 16px,
  'half': '#text' ('modulo': 2),
);

Pow Functions (MathSass)

We borrowed this set of math constants and functions from Takeru Suzuki’s wonderful MathSass library. See the full MIT License below…

@function pow()

Returns base to the exponent power.

Direct access to this function is prefixed, but it is available in all accoutrement maps as 'pow' or '^'.

Parameters & Return

$base: (number)

– The base number

$exp: (number)

The exponent to which to raise base

@return (number)

Result of the equation

Example

scss
/* #{ _a_pow(4, 2)   } */
/* #{ _a_pow(4, -2)  } */
/* #{ _a_pow(4, 0.2) } */
css compiled
/* 16 */
/* 0.0625 */
/* 1.31951 */

Requires

@function _a_exp() [private]

@function log()

Returns the natural logarithm of a number.

Direct access to this function is prefixed, but it is available in all accoutrement maps as 'log'.

Parameters

$x: (number)

$b: (number)

the base number

Example

scss
/* #{ _a_log(2)     } */
/* #{ _a_log(10)    } */
/* #{ _a_log(2, 10) } */
css compiled
/* 0.69315 */
/* 2.30259 */
/* 0.30103 */

Requires

@function _a_frexp() [private]

@function _a_ldexp() [private]

@function _a_log-approx() [private]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.