shapers/ClassicJigSaw. ClassicJigSaw

This is the classic JigSaw Shaper used in puzzle toys, where teeth and slots
are shaped by Bézier curves.

Constructor

new ClassicJigSaw(nx, ny)

ClassicJigSaw constructor

Parameters:
NameTypeDescription
nxnumber

Number of columns

nynumber

Number of rows

Extends

Members

baseWidthFactor :number

ClassicJigSaw needs a biggest base width

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

ClassicJigSaw needs a biggest base height factor

Type:
  • number

Methods

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

hLine(sd, type, x, y, w, h, inv)

Parameters:
NameTypeDescription
sdmodule:AWT.Path

The Path to which the line will be added

typenumber

Type of tooth: 0 is flat (no tooth), 1 means tooth up, and 2 means tooth down

xnumber

X coordinate of the starting point

ynumber

Y coordinate of the starting point

wnumber

Width of the piece

hnumber

Height of the piece

invboolean

The line must be drawn right to left

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

vLine(sd, type, x, y, w, h, inv)

Parameters:
NameTypeDescription
sdmodule:AWT.Path

The Path to which the line will be added

typenumber

Type of tooth: 0 is flat (no tooth), 1 means tooth right, and 2 means tooth left

xnumber

X coordinate of the starting point

ynumber

Y coordinate of the starting point

wnumber

Width of the piece

hnumber

Height of the piece

invboolean

The line must be drawn bottom to top