Home Reference Source
import Scale from 'newton-lib/src/utils/Scale.js'
public class | source

Scale

Stores the scale properties in a particular axis (-x or -y).

Constructor Summary

Public Constructor
public

constructor(px: number, mag: number, unit: string)

Member Summary

Public Members
public

Magnitude of the scale.

public

Number of pixels that one magnitude value is equivalent.

public

Conversion factor from units to pixels.

public

Conversion factor from pixels to units.

public

Units of the scale.

Method Summary

Public Methods
public

set(px: number, mag: number, unit: string)

Sets the scale for the axis.

Public Constructors

public constructor(px: number, mag: number, unit: string) source

Params:

NameTypeAttributeDescription
px number

Number of pixels that one magnitude value is equivalent.

mag number

Magnitude of the scale.

unit string
  • optional
  • default: ""

Unit of the scale.

Public Members

public mag: number source

Magnitude of the scale. Default value is 0.

public px: number source

Number of pixels that one magnitude value is equivalent. Default value is 0.

public toPx: number source

Conversion factor from units to pixels. Default value is 0.

Example:

var pixels = units * scale.toPixels;

public toUnits: number source

Conversion factor from pixels to units. Default value is 0.

Example:

var units = pixels * scale.toUnits;

public unit: string source

Units of the scale. These units are displayed in the axis. Default value is "".

Public Methods

public set(px: number, mag: number, unit: string) source

Sets the scale for the axis. It calculates the conversion factors between pixels and units.

Params:

NameTypeAttributeDescription
px number

Number of pixels that one magnitude value is equivalent.

mag number

Magnitude of the scale.

unit string
  • optional
  • default: ""

Unit of the scale.