Class: Shape

Shape

new Shape()

This Class represents any Shape that can be added to the Sheet.
Source:

Methods

addAlignments()

This Function adds alignment coordinate to sheet memory for any alignment check that other shapes can use
Source:
Returns:
- nothing

addComponent(_component)

This Function adds shape component to a shape A Shape consists of one or many shape components such as text, rectangle, line, path & ellipse etc
Parameters:
Name Type Description
_component ShapeComponent
Source:
Returns:
- nothing

addHover()

This Function adds characterstics to shape during hover This dictates when mouse goes over and out of a shape
Source:
Returns:
- nothing

alignmentCheck(ctx, cw, ch, top, left, bottom, right, bound)

This Function is used to create alignment rail
Parameters:
Name Type Description
ctx 2D_Context this is the context of scratch canvas, this may not be needed in future releases
cw Number width of the shape
ch Number height of the shape
top Number top coordinate of the shape
left Number left coordinate of the shape
bottom Number bottom coordinate of the shape
right Number right coordinate of the shape
bound Number is not currently used
Source:
Returns:
- nothing

click()

This Function defines action during a single click on a shape
Source:
Returns:
- nothing

connectFrom(_beginShape)

This Function creates an incoming connection from another shape to this shape
Parameters:
Name Type Description
_beginShape Shape provide the shape from where the connection is originating
Source:
Returns:
- nothing

connectTo(_endShape)

This Function creates an outgoing connection from this shape to another shape
Parameters:
Name Type Description
_endShape Shape provide the shape where the connection is terminating
Source:
Returns:
- nothing

deleteShape()

This Function deletes the shape
Source:
Returns:
- nothing

doubleClick()

This Function defines action during double click on a shape
Source:
Returns:
- nothing

draw()

This Function is used to draw or paint the shape
Source:
Returns:
- nothing

drawOnCanvas(_context)

This Function is used to paint the shape on HTML Canvas element
Parameters:
Name Type Description
_context 2D_Context provide 2d context for the canvas
Source:
Returns:
- nothing

getArea()

This Function returns the underlying area of the shape under construction
Source:
Returns:
- nothing

getDimension() → {Object}

This Function gets the dimension object of the shape
Source:
Returns:
- dimension - of the shape
Type
Object

getDom() → {HTMLElement}

This Function returns the underlying HTML Dom for this shape
Source:
Returns:
- - This element can be an SVG element too
Type
HTMLElement

lineTo(pos)

This Function draws a temporary line on scratch canvas from the shape on a sheet
Parameters:
Name Type Description
pos Point represents the point where current mouse position is
Source:
Returns:
- nothing

move(pos, clickPos)

This Function defines behavior of Shape when user is moving it
Parameters:
Name Type Description
pos Point contains current mouse position {x,y}
clickPos Point contains start position of the mouse
Source:
Returns:
- nothing

reDraw()

This Function is used to redraw or repaint the shape on the sheet
Source:
Returns:
- nothing

refreshConnection(_context)

This Function refreshes Connections between shapes
Parameters:
Name Type Description
_context 2D_Context this is not needed in the current version
Source:
Returns:
- nothing

removeAlignments()

This Function is removes alignment coordinates for this shape so they will not be used for any alignment checks
Source:
Returns:
- nothing

resizeContinue(pos, clickPos)

This Function is invoked from while resizing event (continue) is going on It dectates the behavior during resizing continuation
Parameters:
Name Type Description
pos Point contains current mouse position {x,y}
clickPos Point contains start position of the mouse
Source:
Returns:
- nothing

resizeStop()

This Function dictates the behavior after resize event is finished
Source:
Returns:
- nothing

save() → {Object}

This function returns saved json format
Source:
Returns:
saved JSON
Type
Object

selectToggle()

This Function is used to hilight or remove hilight from the Shape. Usually invoked during click
Source:
Returns:
- nothing

setDimension(dim)

This Function is used to setDimension of the shape
Parameters:
Name Type Description
dim Object provide dimension object for the shape
Source:
Returns:
- nothing

setPoints(ctx)

This Function is used to set points
Parameters:
Name Type Description
ctx Point this is the context of scratch canvas, this may not be needed in future releases
Source:
Returns:
- nothing

setPosition(pos, align)

This Function is used to set left,top position of the shape
Parameters:
Name Type Description
pos Point position where left and top will be position
align boolean change the position to align with the nearest alignment within 50px (if exists)
Source:
Returns:
- nothing

updateText(_text, _index)

This Function is used to text component within the shape
Parameters:
Name Type Description
_text String new text string
_index Number (optional) sequence of the text to be updated (starts with 0)
Source:
Returns:
- nothing