shapers/Shaper. Shaper

The function of this class and its subclasses is to draw a set of "shapes" that will be used to
place ActiveBox objects at a specific position, and to determine its dimension and
appearance.

Constructor

new Shaper(nx, ny)

Shaper constructor

Parameters:
NameTypeDescription
nxnumber

Number of columns (in grid-based shapers)

nynumber

Number of rows (in grid-based shapers)

Members

baseWidthFactor :number

In JigSaw, ratio between the base width of the tooth and the total length of the side.

Type:
  • number

className :string

This shaper class name

Type:
  • string

customShapes :boolean

Only the Holes shaper has this flag activated

Type:
  • boolean

enclosing :module:AWT.Shape

In Holes, the enclosing area where all shapes are placed.

hasRemainder :boolean

Flag indicating if this Shaper deploys over a surface biggest than the rectangle enclosing
all its shapes

Type:
  • boolean

initiated :boolean

Flag used to check if the Shaper has been initialized against a real surface

Type:
  • boolean

nCells :number

Number of cells managed by this shaper

Type:
  • number

nCols :number

Number of columns (useful in grid-based shapers)

Type:
  • number

nRows :number

Number of rows (useful in grid-based shapers)

Type:
  • number

randomLines :boolean

In JigSaw, whether the tooths take random directions or not

Type:
  • boolean

rectangularShapes :boolean

Flag indicating if this shaper organizes its cells in rows and columns

Type:
  • boolean

scaleX :number

In Holes, scale to be applied to horizontal positions and lengths to achieve the real
value of the shape placed on a real surface.

Type:
  • number

scaleY :number

In Holes, scale to be applied to vertical positions and lengths to achieve the real
value of the shape placed on a real surface.

Type:
  • number

shapeData :object

Contains the specific definition of each shape

Type:
  • object

showEnclosure :boolean

In Holes, when true, the enclosing area will be drawn

Type:
  • boolean

toothHeightFactor :number

In JigSaw, ratio between the tooth height and the total length of the side.

Type:
  • number

(static) CLASSES :object

List of known classes derived from Shaper. It should be filled by real shaper classes at
declaration time.

Type:
  • object

Methods

buildShapes()

Builds the individual shapes that will form this Shaper

getAttributes() → {object}

Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.

Returns:
  • The resulting object, with minimal attrributes
Type: 
object

getEnclosingShapeData() → {module:AWT.Rectangle}

Gets the AWT.Rectangle that contains all shapes of this Shaper.

Returns:
Type: 
module:AWT.Rectangle

getRemainderShape(rect) → {module:AWT.Rectangle}

When hasRemainder is true, this method gets the rectangle containing the full surface where
the Shaper develops.

Parameters:
NameTypeDescription
rectmodule:AWT.Rectangle

The frame where to move and scale all the shapes

Returns:
Type: 
module:AWT.Rectangle

getShape(n, rect) → {module:AWT.Shape}

Gets a clone of the nth Shape object, scaled and located inside a Rectangle

Parameters:
NameTypeDescription
nnumber
rectmodule:AWT.Rectangle
Returns:
Type: 
module:AWT.Shape

getShapeData(n) → {object}

Gets the nth Shape data object

Parameters:
NameTypeDescription
nnumber
Returns:
Type: 
object

reset(nCols, nRows)

Initializes this Shaper to default values

Parameters:
NameTypeDescription
nColsnumber

Number of columns

nRowsnumber

Number of rows

setProperties($xml)

Loads this shaper settings from a specific JQuery XML element

Parameters:
NameTypeDescription
$xmlexternal:jQuery

The XML element with the shaper data

(static) factory(data) → {module:shapers/Shaper.Shaper}

Builds a new shaper, based on the properties specified in a data object

Parameters:
NameTypeDescription
dataobject

The data object to be parsed

(static) getShaper(className, nx, ny) → {module:shapers/Shaper.Shaper}

Factory constructor that returns a Shaper of the requested class.

Parameters:
NameTypeDescription
classNamestring

The class name of the requested Shaper.

nxnumber

Number of columns (in grid-based shapers)

nynumber

Number of rows (in grid-based shapers)

(static) readShapeData($xml, scaleX, scaleY) → {module:AWT.Shape}

Reads an individual shape from an XML element.
Shapes are arrays of stroke objects.
Each stroke has an action (move to, line to, quad to...) and associated data.

Parameters:
NameTypeDescription
$xmlexternal:jQuery

The XML element with the shape data

scaleXnumber
scaleYnumber
Returns:
Type: 
module:AWT.Shape

(static) registerClass(shaperName, shaperClass) → {module:shapers/Shaper.Shaper}

Registers a new type of shaper

Parameters:
NameTypeDescription
shaperNamestring

The name used to identify this shaper

shaperClassfunction

The shaper class, usually extending Shaper

Returns:
  • The provided shaper class
Type: 
module:shapers/Shaper.Shaper