Home Reference Source Test Repository

Function

Static Public Summary
public

bezierDerivative(t: number, start: Point, control: Point, end: Point): Point

Find the derivative of a quadratic bezier at a given point.

public

calcBezierDistance(pointX: number, pointY: number, start: Point, control: Point, end: Point): number

Function that calculates the distance between a specified point and a quadratic bezier.

public

Create an html string for a form given an array of field types.

public

createGraphForm(fields: Array<InputType>, canSubmit: boolean, submitText: string): string

Create a form with inputs for graph elements.

public

displayError(form: Element, inputName: string, showError: boolean)

Add/remove the CSS class 'error' to the specified form input.

public

getData(form: Element, graph: Graph): Object<string, *>

Get all of the data from a form.

public

Get the value of the given form input.

public

Get the value of a single input.

public

init()

Call to initialize form functionality.

public

scrollToElement(element: Element, to: number, speed: number, easing: string)

Function to scroll to an element.

Static Public

public bezierDerivative(t: number, start: Point, control: Point, end: Point): Point source

import {bezierDerivative} from 'canvas-graph-creator/src/js/util/bezier.js'

Find the derivative of a quadratic bezier at a given point.

Params:

NameTypeAttributeDescription
t number

The point in the curve P(t) to find the derivative at.

start Point

The start point of the bezier curve.

control Point

The control point of the bezier curve.

end Point

The end point of the bezier curve.

Return:

Point

Point object containing the x- and y-values of the derivative.

public calcBezierDistance(pointX: number, pointY: number, start: Point, control: Point, end: Point): number source

import {calcBezierDistance} from 'canvas-graph-creator/src/js/util/bezier.js'

Function that calculates the distance between a specified point and a quadratic bezier.

Params:

NameTypeAttributeDescription
pointX number

x-coordinate of the specified point.

pointY number

y-coordinate of the specified point.

start Point

The start point of the bezier curve.

control Point

The control point of the bezier curve.

end Point

The end point of the bezier curve.

Return:

number

The distance between (pointX, pointY) and the bezier curve specified by start, control, and end.

public createForm(fields: Array<InputType>): string source

import {createForm} from 'canvas-graph-creator/src/js/ui/form.js'

Create an html string for a form given an array of field types.

Params:

NameTypeAttributeDescription
fields Array<InputType>

Array of input types.

Return:

string

String containing HTML for the form.

public createGraphForm(fields: Array<InputType>, canSubmit: boolean, submitText: string): string source

import {createGraphForm} from 'canvas-graph-creator/src/js/ui/form.js'

Create a form with inputs for graph elements. Also has options for a button to submit the form.

Params:

NameTypeAttributeDescription
fields Array<InputType>

Array of input types.

canSubmit boolean

Whether or not the form can be submitted.

submitText string

Text to be displayed on the submit button.

Return:

string

String containing HTML for the form.

public displayError(form: Element, inputName: string, showError: boolean) source

import {displayError} from 'canvas-graph-creator/src/js/ui/form.js'

Add/remove the CSS class 'error' to the specified form input.

Params:

NameTypeAttributeDescription
form Element

Form dom element.

inputName string

Name of the input.

showError boolean

Whether or not the input should display an error.

public getData(form: Element, graph: Graph): Object<string, *> source

Get all of the data from a form.

Params:

NameTypeAttributeDescription
form Element

Form DOM element.

graph Graph

The current graph object.

Return:

Object<string, *>

Object containing input names and their associated input values

public getInputValue(input: Element): boolean | number | string source

import {getInputValue} from 'canvas-graph-creator/src/js/ui/form.js'

Get the value of the given form input.

Params:

NameTypeAttributeDescription
input Element

Form input DOM element.

Return:

boolean | number | string

Value of the input.

public getInputValueLocal(input: Element, graph: Graph): boolean | number | string | Node | Edge source

import {getInputValueLocal} from 'canvas-graph-creator/src/js/ui/form.js'

Get the value of a single input. Used when the input could contain a reference to a Node or Edge.

Params:

NameTypeAttributeDescription
input Element

Form input DOM element.

graph Graph

Graph object.

Return:

boolean | number | string | Node | Edge

The value of the input.

public init() source

Call to initialize form functionality.

public scrollToElement(element: Element, to: number, speed: number, easing: string) source

Function to scroll to an element. Based on scrollToY from http://stackoverflow.com/a/16136789/1418962

Params:

NameTypeAttributeDescription
element Element

The elemnt to scroll to.

to number

Number indicating offset from the top of the element.

speed number

Speed to scroll.

easing string

Name of easing function (default: 'easeOutSine').