Class: CoordinateSystem

CoordinateSystem

Contain functions to pass between different coordinate system. Here described the coordinate system in sequence

  • CanvasHTML: Html coordinates: 0,0 left,top to width height at bottom right (y Down)
  • CanvasContext: Same as Html, but scaled by devicePixelRatio (y Down) (required for WebGL, not for SVG)
  • Viewport: 0,0 left,bottom to (width,height) at top right (y Up)
  • Center: 0,0 at viewport center (y Up)
  • Scene: 0,0 at dataset center (y Up). The dataset is placed here through the camera transform
  • Layer: 0,0 at Layer center (y Up). Layer is placed over the dataset by the layer transform
  • Image: 0,0 at left,top (y Down)
  • Layout: 0,0 at left,top (y Down). Depends on layout

new CoordinateSystem()

Source:

Methods


<static> fromCanvasHtmlToImage(p, camera, layerT, layerSize, applyGLScale)

Transform a point from CanvasHtml to Image

Parameters:
Name Type Description
p *

point {x, y} in CanvasHtml (0,0 left,top, y Down)

camera Camera

camera

layerT Transform

layer transform

layerSize *

{w, h} Size in pixel of the Layer

applyGLScale bool

if true apply devPixelRatio scale. Keep it false when working with SVG

Source:
Returns:

Point in Image space (0,0 left,top of the image, y Down)


<static> fromCanvasHtmlToScene(p, camera, useGL)

Transform a point from CanvasHtml to Scene

Parameters:
Name Type Description
p *

point {x, y} in CanvasHtml (0,0 left,top, y Down)

camera Camera

camera

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

Point in Scene coordinates (0,0 at scene center, y Up)


<static> fromCanvasHtmlToViewport(p, camera, useGL)

Transform point from CanvasHTML to GLViewport

Parameters:
Name Type Description
p *

point in CanvasHtml: 0,0 left,top y Down

camera Camera

Camera

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

point in GLViewport: 0,0 left,bottom, scaled by devicePixelRatio


<static> fromLayerBoxToSceneBox(box, layerT)

Transform a box from Layer to Scene

Parameters:
Name Type Description
box BoundingBox

box in Layer coordinates (0,0 at layer center)

layerT Transform

layer transform

Source:
Returns:

box in Scene coordinates (0,0 at scene center)


<static> fromLayerBoxToViewportBox(box, camera, layerT, useGL)

Transform a box from Layer to Viewport coordinates

Parameters:
Name Type Description
box BoundingBox

box in Layer coordinates (0,0 at Layer center y Up)

camera Camera
layerT Transform

layer transform

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

Box in Viewport coordinates (0,0 at left, bottom y Up)


<static> fromLayerToCenter(p, camera, layerT)

Transform a point from Layer to Center

Parameters:
Name Type Description
p *

point {x,y} in Layer coordinates (0,0 at Layer center)

camera Camera

camera

layerT Transform

layer transform

Source:
Returns:

point in Center (0, 0 at glViewport center) coordinates.


<static> fromLayerToImage(p, layerSize)

Transform a point from Layer to Image coordinates

Parameters:
Name Type Description
p *

point {x, y} Layer coordinates (0,0 at Layer center)

layerSize *

{w, h} Size in pixel of the Layer

Source:
Returns:

Point in Image coordinates (0,0 at left,top, y Down)


<static> fromLayerToViewport(p, camera, layerT, useGL)

Transform a point from Layer to Viewport coordinates

Parameters:
Name Type Description
p *

point {x,y} Layer (0,0 at Layer center y Up)

camera Camera
layerT Transform

layer transform

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

point in viewport coordinates (0,0 at left,bottom y Up)


<static> fromSceneBoxToLayerBox(box, layerT)

Transform a box from Scene to Layer

Parameters:
Name Type Description
box BoundingBox

box in Layer coordinates (0,0 at layer center)

layerT Transform

layer transform

Source:
Returns:

box in Scene coordinates (0,0 at scene center)


<static> fromSceneToCanvasHtml(p, camera, useGL)

Transform a point from Scene to CanvasHtml

Parameters:
Name Type Description
p *

point {x, y} Scene coordinates (0,0 at scene center, y Up)

camera Camera

camera

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

Point in CanvasHtml (0,0 left,top, y Down)


<static> fromSceneToViewport(p, camera, useGL)

Transform a point from Scene to Viewport

Parameters:
Name Type Description
p *

point {x, y} Scene coordinates (0,0 at scene center, y Up)

camera Camera

camera

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

Point in Viewport (0,0 left,bottom, y Up)


<static> fromSceneToViewportNoCamera(p, cameraT, viewport)

Transform a point from Scene to Viewport, using given transform and viewport

Parameters:
Name Type Description
p *

point {x, y} Scene coordinates (0,0 at scene center, y Up)

cameraT Transform

camera transform

viewport *

viewport {x,y,dx,dy,w,h}

Source:
Returns:

Point in Viewport (0,0 left,bottom, y Up)


<static> fromViewportBoxToImageBox(box, cameraT, viewport, layerT, layerSize)

Transform a box from Viewport to Image coordinates

Parameters:
Name Type Description
box BoundingBox

in Viewport coordinates (0,0 at left,bottom, y Up)

cameraT Transform

camera Transform

viewport *

{x,y,dx,dy,w,h}

layerT Transform

layer transform

layerSize *

{w,h} layer pixel size

Source:
Returns:

box in Image coordinates (0,0 left,top, y Dowm)


<static> fromViewportBoxToLayerBox(box, camera, layerT, useGL)

Transform a box from Layer to Viewport coordinates

Parameters:
Name Type Description
box BoundingBox

box in Layer coordinates (0,0 at Layer center y Up)

camera Camera
layerT Transform

layer transform

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

Box in Viewport coordinates (0,0 at left, bottom y Up)


<static> fromViewportToCanvasHtml(p, camera, useGL)

Transform point from Viewport to CanvasHTML

Parameters:
Name Type Description
p *

point in Viewport: 0,0 at left,bottom

camera Camera

Camera which contains viewport information

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

point in CanvasHtml: 0,0 left,top


<static> fromViewportToLayer(p, camera, layerT, useGL)

Transform a point from Viewport to Layer coordinates

Parameters:
Name Type Description
p *

point {x,y} in Viewport (0,0 left,bottom, y Up)

camera Camera

camera

layerT Transform

layer transform

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

point in Layer coordinates (0, 0 at layer center, y Up)


<static> fromViewportToScene(p, camera, useGL)

Transform a point from Viewport to Scene.

Parameters:
Name Type Description
p *

point {x, y} Viewport coordinates (0,0 at left,bottom, y Up)

camera Camera

camera

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

Point in Viewport (0,0 at scene center, y Up)


<static> fromViewportToSceneNoCamera(p, cameraT, viewport)

Transform a point from Viewport to Scene, using given transform and viewport

Parameters:
Name Type Description
p *

point {x, y} Viewport coordinates (0,0 at left,bottom, y Up)

cameraT Transform

camera transform

viewport *

viewport {x,y,dx,dy,w,h}

Source:
Returns:

Point in Viewport (0,0 at scene center, y Up)


<static> getFromLayerToViewportTransform(camera, layerT, useGL)

Get a transform to go from Layer (0,0 at Layer center y Up) to Viewport (0,0 at left,bottom y Up)

Parameters:
Name Type Description
camera Camera
layerT Transform

layer transform

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

transform from Layer to Viewport


<static> getFromLayerToViewportTransformNoCamera(CameraT, viewport, layerT)

Get a transform to go from Layer (0,0 at Layer center y Up) to Viewport (0,0 at left,bottom y Up)

Parameters:
Name Type Description
CameraT Transform

camera transform

viewport viewport

{x,y,dx,dy,w,h} viewport

layerT Transform

layer transform

Source:
Returns:

transform from Layer to Viewport


<static> getFromViewportToCenterTransform(camera, useGL)

Get a transform to go from viewport 0,0 at left, bottom y Up, to Center 0,0 at viewport center

Parameters:
Name Type Description
camera Camera

camera

useGL bool

True to work with WebGL, false for SVG. When true, it uses devPixelRatio scale

Source:
Returns:

transform from Viewport to Center


<static> getFromViewportToCenterTransformNoCamera(viewport)

Get a transform to go from viewport 0,0 at left, bottom y Up, to Center 0,0 at viewport center from explicit viewport param. (Not using camera parameter here)

Parameters:
Name Type Description
viewport *

viewport

Source:
Returns:

transform from Viewport to Center


<static> getViewport(useGL)

Return the camera viewport: scaled by devicePixelRatio if useGL is true.

Parameters:
Name Type Description
useGL bool

True to work with WebGL, false for SVG. When true viewport scaled by devPixelRatio

Source:
Returns:

Viewport


<static> invertY(p, viewport)

Invert y with respect to viewport.h

Parameters:
Name Type Description
p *

Point to be transformed

viewport *

current viewport

Source:
Returns:

Point with y inverted with respect to viewport.h


<static> reflectY(t)

Return transform with y reflected wrt origin (y=-y)

Parameters:
Name Type Description
t Transform
Source:
Returns:

transform, with y reflected (around 0)

Type
Transform

<static> scale(p, f)

Scale x applying f scale factor

Parameters:
Name Type Description
p *

Point to be scaled

f Number

Scale factor

Source:
Returns:

Point in CanvasContext (Scaled by devicePixelRation)