Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IDivisionsOptions<T>

The construction options for the Divisions class

Type parameters

  • T

Hierarchy

  • IDivisionsOptions

Index

Properties

Methods

Properties

base

base: T | IDivisionsOverrides<T>

Specify the base 500 devision or override some or all of the divisions

example
Overriding divisions ```ts { base: { 500: 10, 700: 99, 900: 1000 }} ```

Optional scale

scale: Scale

The scale to use when invoking the ratio callback. Defaults to scale. Can be specified as a custom value using (2 as Scale)

example
import { Divisions, defaultScale, Scale } from '@ef-carbon/react-native-style';
function ratio(last: number, ratio: number): number {
  return last * ratio;
}
const defaultScaling = new Divisions<number>({
  base: 100,
  scale: defaultScale,
  ratio,
});
const enumeration = new Divisions<number>({
  base: 100,
  scale: Scale.PerfectFifth,
  ratio,
});
const custom = new Divisions<number>({
  base: 100,
  scale: (4 as Scale),
  ratio,
});

Methods

ratio

  • ratio(last: T, ratio: number, normal?: T): T
  • A callback that is invoked to generate the divisions

    example
    A simple callback ```ts { ratio: (last, ratio) => last * ratio } ```
    example
    Usage with the class ```ts import { Divisions } from '@ef-carbon/react-native-style'; function ratio(last: number, ratio: number): number { return last * ratio; } const divisions = new Divisions({ base: 100, ratio }); ```

    Parameters

    • last: T

      The previous step value

    • ratio: number

      The scale passed as an option. Will be negative when calculating the lower divisions

    • Optional normal: T

      The 500 division

    Returns T