Class: CoordinateMapper

algeobraCanvas~CoordinateMapper(params)

A helper class to handle coordinate transformations between an output surface and an abstract coordinate space

Constructor

new CoordinateMapper(params)

Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
x0 Number <optional>
The x origin
y0 Number <optional>
The y origin
x1 Number <optional>
The x end
x1 Number <optional>
The y end
flipY Boolean <optional>
Specifies whether the y axis should be flipped
width Number The width of the output
height Number The height of the output
Source:

Methods

convertLocalAngleToSurface(a) → {Number}

Converts a local angle to output surface angle
Parameters:
Name Type Description
a Number The local angle
Source:
Returns:
The transformed angle
Type
Number

convertLocalToSurface(x, y) → {Object}

Converts a local coordinate to the output surface space
Parameters:
Name Type Description
x Number
y Number
Source:
Returns:
The transformed coordinate
Type
Object

convertSurfaceToLocal(x, y) → {Object}

Converts a output surface coordinate to the local space
Parameters:
Name Type Description
x Number
y Number
Source:
Returns:
The transformed coordinate
Type
Object

isCounterClockwise()

Source:
Returns:
True, if angles are measured counter-clockwise on the output surface, false otherwise

scalingLocalToSurface() → {Number}

The scaling factor that scales local lengths to the output surface space. The viewport is uniformly scaled, so it is just a single value
Source:
Returns:
The scaling factor
Type
Number

scalingSurfaceToLocal() → {Number}

The scaling factor that scales local lengths to the output surface space. The viewport is uniformly scaled, so it is just a single value
Source:
Returns:
The scaling factor
Type
Number

updateViewport(params)

Update the visible viewport
Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
x0 Number <optional>
The x origin
y0 Number <optional>
The y origin
x1 Number <optional>
The x end
x1 Number <optional>
The y end
Source: