JigSaw
Extends: module:shapers/Shaper.Shaper
Source: JigSaw.js:40
This Shaper returns a set of rectangular shapes with teeth and slots that fit between them.
Constructor
new JigSaw(nx: number, ny: number): JigSawJigSaw constructor
Parameters
nx(number) — Number of columnsny(number) — Number of rows
Instance Methods
buildShapes()
Builds the jigsaw shapes based on the number of rows and columns
hLine(
sd: module:AWT.Path,
type: number,
x: number,
y: number,
w: number,
h: number,
inv: boolean,
)
Adds an horizontal line to the provided path
Parameters
sd(module:AWT.Path) — The Path to which the line will be addedtype(number) — Type of tooth: 0 is flat (no tooth), 1 means tooth up, and 2 means tooth downx(number) — X coordinate of the starting pointy(number) — Y coordinate of the starting pointw(number) — Width of the pieceh(number) — Height of the pieceinv(boolean) — The line must be drawn right to left
vLine(
sd: module:AWT.Path,
type: number,
x: number,
y: number,
w: number,
h: number,
inv: boolean,
)
Adds a vertical line to the provided path
Parameters
sd(module:AWT.Path) — The Path to which the line will be addedtype(number) — Type of tooth: 0 is flat (no tooth), 1 means tooth right, and 2 means tooth leftx(number) — X coordinate of the starting pointy(number) — Y coordinate of the starting pointw(number) — Width of the pieceh(number) — Height of the pieceinv(boolean) — The line must be drawn bottom to top
reset(nCols: number, nRows: number)
Inherited from module:shapers/Shaper.Shaper#reset
Overrides: module:shapers/Shaper.Shaper#reset
Initializes this Shaper to default values
Parameters
nCols(number) — Number of columnsnRows(number) — Number of rows
setProperties($xml: external:jQuery)
Inherited from module:shapers/Shaper.Shaper#setProperties
Overrides: module:shapers/Shaper.Shaper#setProperties
Loads this shaper settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The XML element with the shaper data
getAttributes(): object
Inherited from module:shapers/Shaper.Shaper#getAttributes
Overrides: module:shapers/Shaper.Shaper#getAttributes
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
object
buildShapes()
Inherited from module:shapers/JigSaw.JigSaw#buildShapes
Overrides: module:shapers/Shaper.Shaper#buildShapes
Builds the jigsaw shapes based on the number of rows and columns
getShape(
n: number,
rect: module:AWT.Rectangle,
): module:AWT.Shape
Inherited from module:shapers/Shaper.Shaper#getShape
Overrides: module:shapers/Shaper.Shaper#getShape
Gets a clone of the nth Shape object, scaled and located inside a Rectangle
Parameters
n(number)rect(module:AWT.Rectangle)
Returns
getShapeData(n: number): object
Inherited from module:shapers/Shaper.Shaper#getShapeData
Overrides: module:shapers/Shaper.Shaper#getShapeData
Gets the nth Shape data object
Parameters
n(number)
Returns
object
getEnclosingShapeData(): module:AWT.Rectangle
Inherited from module:shapers/Shaper.Shaper#getEnclosingShapeData
Overrides: module:shapers/Shaper.Shaper#getEnclosingShapeData
Gets the AWT.Rectangle that contains all shapes of this Shaper.
Returns
getRemainderShape(
rect: module:AWT.Rectangle,
): module:AWT.Rectangle
Inherited from module:shapers/Shaper.Shaper#getRemainderShape
Overrides: module:shapers/Shaper.Shaper#getRemainderShape
When hasRemainder is true, this method gets the rectangle containing the full surface where
the Shaper develops.
Parameters
rect(module:AWT.Rectangle) — The frame where to move and scale all the shapes
Returns
buildShapes()
Inherited from module:shapers/JigSaw.JigSaw#buildShapes
Overrides: module:shapers/Shaper.Shaper#buildShapes
Builds the jigsaw shapes based on the number of rows and columns
Static Methods
registerClass(
shaperName: string,
shaperClass: function,
): module:shapers/Shaper.Shaper
Inherited from module:shapers/Shaper.Shaper
Registers a new type of shaper
Parameters
shaperName(string) — The name used to identify this shapershaperClass(function) — The shaper class, usually extending Shaper
Returns
getShaper(
className: string,
nx: number,
ny: number,
): module:shapers/Shaper.Shaper
Inherited from module:shapers/Shaper.Shaper
Factory constructor that returns a Shaper of the requested class.
Parameters
className(string) — The class name of the requested Shaper.nx(number) — Number of columns (in grid-based shapers)ny(number) — Number of rows (in grid-based shapers)
Returns
readShapeData(
$xml: external:jQuery,
scaleX: number,
scaleY: number,
): module:AWT.Shape
Inherited from module:shapers/Shaper.Shaper
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
$xml(external:jQuery) — The XML element with the shape datascaleX(number)scaleY(number)
Returns
factory(data: object): module:shapers/Shaper.Shaper
Inherited from module:shapers/Shaper.Shaper
Builds a new shaper, based on the properties specified in a data object
Parameters
data(object) — The data object to be parsed
Returns
Instance Fields
className: string
Inherited from module:shapers/Shaper.Shaper#className
Overrides: module:shapers/Shaper.Shaper#className
This shaper class name
nCols: number
Inherited from module:shapers/Shaper.Shaper#nCols
Overrides: module:shapers/Shaper.Shaper#nCols
Number of columns (useful in grid-based shapers)
nRows: number
Inherited from module:shapers/Shaper.Shaper#nRows
Overrides: module:shapers/Shaper.Shaper#nRows
Number of rows (useful in grid-based shapers)
nCells: number
Inherited from module:shapers/Shaper.Shaper#nCells
Overrides: module:shapers/Shaper.Shaper#nCells
Number of cells managed by this shaper
shapeData: object
Inherited from module:shapers/Shaper.Shaper#shapeData
Overrides: module:shapers/Shaper.Shaper#shapeData
Contains the specific definition of each shape
initiated: boolean
Inherited from module:shapers/Shaper.Shaper#initiated
Overrides: module:shapers/Shaper.Shaper#initiated
Flag used to check if the Shaper has been initialized against a real surface
baseWidthFactor: number
Inherited from module:shapers/Shaper.Shaper#baseWidthFactor
Overrides: module:shapers/Shaper.Shaper#baseWidthFactor
In JigSaw, ratio between the base width of the tooth and the total length of the side.
toothHeightFactor: number
Inherited from module:shapers/Shaper.Shaper#toothHeightFactor
Overrides: module:shapers/Shaper.Shaper#toothHeightFactor
In JigSaw, ratio between the tooth height and the total length of the side.
randomLines: boolean
Inherited from module:shapers/Shaper.Shaper#randomLines
Overrides: module:shapers/Shaper.Shaper#randomLines
In JigSaw, whether the tooths take random directions or not
scaleX: number
Inherited from module:shapers/Shaper.Shaper#scaleX
Overrides: module:shapers/Shaper.Shaper#scaleX
In Holes, scale to be applied to horizontal positions and lengths to achieve the real
value of the shape placed on a real surface.
scaleY: number
Inherited from module:shapers/Shaper.Shaper#scaleY
Overrides: module:shapers/Shaper.Shaper#scaleY
In Holes, scale to be applied to vertical positions and lengths to achieve the real
value of the shape placed on a real surface.
enclosing: module:AWT.Shape
Inherited from module:shapers/Shaper.Shaper#enclosing
Overrides: module:shapers/Shaper.Shaper#enclosing
In Holes, the enclosing area where all shapes are placed.
showEnclosure: boolean
Inherited from module:shapers/Shaper.Shaper#showEnclosure
Overrides: module:shapers/Shaper.Shaper#showEnclosure
In Holes, when true, the enclosing area will be drawn
rectangularShapes: boolean
Inherited from module:shapers/Shaper.Shaper#rectangularShapes
Overrides: module:shapers/Shaper.Shaper#rectangularShapes
Flag indicating if this shaper organizes its cells in rows and columns
hasRemainder: boolean
Inherited from module:shapers/Shaper.Shaper#hasRemainder
Overrides: module:shapers/Shaper.Shaper#hasRemainder
Flag indicating if this Shaper deploys over a surface biggest than the rectangle enclosing
all its shapes
customShapes: boolean
Inherited from module:shapers/Shaper.Shaper#customShapes
Overrides: module:shapers/Shaper.Shaper#customShapes
Only the Holes shaper has this flag activated
Static Fields
CLASSES: object
Inherited from module:shapers/Shaper.Shaper
List of known classes derived from Shaper. It should be filled by real shaper classes at
declaration time.