Module: algeobraCanvas

Classes

CanvasPathOutput
CoordinateMapper
DiagramCanvas
DiagramPainter
DrawFuncRegistry
PathOutput
PointManipulator
ScenePainter
SvgPathOutput

Members

(inner, constant) BASIC_BACKGROUND_CONFIG

Configuration for a basic background with a coordinate system
Source:

(inner, constant) NO_BACKGROUND_CONFIG

Configuration to draw no background
Source:

(inner, constant) styles

Style properties for drawing on a canvas
Source:

Methods

(inner) clientPositionToLocal(x, y, element) → {Object}

Helper function to transform client coordinates into coordinates local to the given element
Parameters:
Name Type Description
x Number The x position
y Number The y position
element HTMLElement The element to be relative to
Source:
Returns:
The relative coordinates
Type
Object

(inner) clipLineAtScreen(coordinateMapper, x0, y0, x1, y1, leftOpen, rightOpen) → {Object}

Clips a possibly infinite line against a viewport
Parameters:
Name Type Description
coordinateMapper CoordinateMapper The coordinate mapper
x0 Number First point x coordinate
y0 Number First point y coordinate
x1 Number Second point x coordinate
y1 Number Second point y coordinate
leftOpen Boolean Specifies, whether the line extends to infinity from the first point
rightOpen Boolean Specifies, whether the line extends to infinity from the second point
Source:
Returns:
The clipped end points of the line
Type
Object

(inner) createDiagramCanvasDrawFuncRegistry() → {DrawFuncRegistry}

Fills a DrawFuncRegistry with default functions for the predefined algeobra types
Source:
Returns:
Default diagram drawing functions for algeobra types
Type
DrawFuncRegistry

(inner) drawSceneToDiagram(scene, diagram, params)

Draws a scene to a given diagram
Parameters:
Name Type Attributes Description
scene GeometryScene The scene to be drawn
diagram DiagramCanvas The diagram to write into
params Object
Properties
Name Type Attributes Description
drawFunc DrawFuncRegistry <optional>
A registry of drawing functions. Uses default implementation, if not given
parmas.bg Object <optional>
The background definition. Defaults to NO_BACKGROUND_CONFIG if not given
Source:

(inner) makeTicks(spacing, coordStart, coordLength, flip, outStart, outLength) → {Array}

Parameters:
Name Type Description
spacing Number The spacing in coordinate space
coordStart Number Start of the coordinate range
coordLength Number Length of the coordinate range
flip Boolean If true, coordinates gets flipped
outStart Number Start of the output range
outLength Number Length of the output range
Source:
Returns:
Offsets
Type
Array

(inner) mouseEventToPosition(e) → {Object}

Helper function to transform mouse event coordinates into coordinates local to the element it happened on
Parameters:
Name Type Description
e Object The mouse event
Source:
Returns:
The relative coordinates
Type
Object

(inner) sortDrawables(scene) → {Array.<{value: Object, z: Number, properties: Object}>}

This sorts the objects in the scene, according to their z-value, if present. Default z is 0. Objects may be excluded from drawing by adding a "invisible" property and setting it to true
Parameters:
Name Type Description
scene GeometryScene The scene
Source:
Returns:
Sorted list of objects to be drawn
Type
Array.<{value: Object, z: Number, properties: Object}>