Repository navigation
Technical indexing
Any comment not preceded by a character, that contains any amount of spaces followed by [digit] or [digit.digit].
Regex :
(?!\w+)\s*//(?!\s*\w)(\s*\[.*\d+\.\d+.*\].*|.*\[.*\d+.*\].*)
Creates the THREE.js canvas containing the interesting part of the app.
Shared and used between many files
See Tiling.js [ 2.0 ]
Tiling.js [ 2.2 ] [ 2.6 ]
Tiling.js [ 2.2 ] [ 2.6 ]
the currentIdentity variable. Tiling.js [ 2.4 ] [ 2.5 ]
Tiling.js [ 2.5 ]
Tiling.js [ 2.4 ]
complex operations over the current Tiling. This section could be improved ... Tiling.js [ 2.3 ] [ 2.4 ] [ 2.5 ]
See Tiling [ 2.0 ]
Called by a routine.
the THREE.js Canvas. App.js [ 1.0 ]
the html element. Called by a routine.
See Tiling
The tile contains a list of its neighbors, all tiles are included in a Tiling. See [ 2.0 ]
This class contains maily a list of Tiles, which themselves contains references to their neighbors. This class also contains the THREE.js Objects displayed in the app.
The tile contains a list of its neighbors, all tiles are included in a Tiling. See [ 2.0 ]
This class contains maily a list of Tiles, which themselves contains references to their neighbors. This class also contains the THREE.js Objects displayed in the app.
Used directly by Sandpiles.html
See Tiling.js [ 2.0 ] and [ 2.6 ] for the use of colormaps.
Used directly by Sandpiles.html
the operation max_stable + Identity. Calculates radius by estimating the center of mass of the tiling, or by measuring from the center of canvas space. This section could be improved. -> Make a better center estimation -> Let the user choose or not to compute the estimated center -> Apply direclty max_stable + identity
to all measures of roundness
Same as ImportExport.js [ 2.0 ]
toppling of the Tiling.
of the current Tiling.
Same as ImportExport.js [ 2.0 ]
[4] I am lazy
Tiling objects.
tile ids are arrays of strings, where:
- the first string is the tile type,
- the second is a unique string in the base tiling,
- each subsequent string identifies the child of a parent tile (uses push method) THESE IDENTIFIERS MUST BE UNIQUE
How to use this API? see [1] to [7]
"side effect" = a function modifies directly the objects it receives as argument
remark: each one must have a unique id identifying the type e.g. ['kite'] or ['dart']
remark: it may be useful for the substitution to have some typeX2typeY method, converting (by side effect) some tile of typeX to typeY at the "same position" with the "same orientation". e.g. Tile.prototype.kite2dart = function(){ update id[0] and move bounds } geometric point transformations provided by Utils/Geometry.js may be useful
remark: neighbors may be left empty [] or set all neighbors as undefined [undefined,undefined,...,undefined] (remember this when creating you base tiling at step [7])
input:
- Tile output:
- (Array of) Tile
useful methods:
- Tile.myclone()
- Tile.typeX2typeY()
- Tile.scale(...)
- Tile.rotate(...)
- Tile.shift(...) depending on how you code neighbors computation:
- Tile.resetNeighbors()
remark: newtiles are supposed to be scaled down by 1/ratio, with ratio the value passed to substitute at step [7]
remark: should may use "switch(tile.id[0]){...}" for the different tile types
remark: the substitution may create duplicated tiles
'mydupinfos' an Array of DupInfo, and 'mydupinfosoriented' an Array of DupInfoOriented
indeed, it often happens that the subsitution "déborde" and as a consequence, neighboring parent tiles may create twice a same newtile. If your substitution is very nice and does not have this issue, then simply set 'mydupinfo=[];'. Otherwise init to [] and then 'mydupinfo.push(new Dupinfo(...));' for each potential duplicate case.
data structure storing informations about the potential duplicated children of a parent tile
meaning: if parent is 'ptype' and parent.neighbors['index'] is 'potype', then "'id' child of parent" is a duplicate of "'oid' child of parent.neighbors['index']" (both are 'type')
data structure storing informations about the potential duplicated children of a parent tile, when this also depends on the matching side of neighbor tile (thus on the orientation of the neighboring tile)
meaning: if parent is 'ptype' and parent.neighbors['index'] is 'potype', and if furthermore the former is neighbor 'oindex' of the latter, then "'id' child of parent" is a duplicate of "'oid' child of parent.neighbors['index']" (both are 'type')
construct a map of duplicated tiles:
- idkey of duplicated -> id of original from:
- an Array of DupInfo
- an Array of Tile
check if child id of pid is a duplicated tile, with
- newdup the map of duplicated tiles
- pid the parend of id (Array)
- id the child id (last part)
- type the child type
neighbors of the new tiles input:
- Array of tiles
- Map of tiles (idkey -> tile)
- Array of newtiles (obtained from 'mysubstitution')
- Map of newtiles (newidkey -> newtile)
- Map of duplicated newtiles (newidkey -> id of original) no output, just return;
remark: newtiles' neighbors are computed based on the parent's neighbors, therefore it may be natural to iterate over parent tiles.
remark: you may have used Tile.resetNeighbors() at step [2]
remark: no need to fill the neighbors of duplicated tiles (see isDup at [3.3])
remark: the cleaning of duplicated tiles at step [5] will update the neighbors which are duplicated tiles. It means that you may set as neighbors some tiles which turn out to be duplicated, the replacement for the original tile will be handled automatically from your 'mydupinfos'
remark: maps (aka dictionaries) may be useful to get the neighbor of a neighbor, do not forget to use id2key(id) (see [0.1]) when calling .has and .get methods.
see useful methods [4.1] to [4.3]
modifies
- tilesdict (map of tiles with id2key) by adding child nid (of type ntype) of pnid as neighbor number i of child id (of type type) of pid, with:
- pid the parent id (Array)
- id the child id (last part)
- type the child type
- i the neighbors index (integer)
- pnid the neighbors parent id (Array)
- nid the neighbors id (last part)
- ntype the neighbors type
similar to setNeighbor
(if it is then set the original as neighbor) similar to setNeighbor CAUTION: not useful because clean updates duplicated tiles in neighbors
findNeighbors checks if non-neighboring tiles have neighborhing children, in time O(n log n) with n the number of undefined neighbors (hoping that javascript Array.sort() implements quicksort)remark: the default correspondence is that tile.neighbors[i] corresponds to segment (tile.bounds[2i],tile.bounds[2i+1]) -- (tile.bounds[2i+2 %_],tile.bounds[2i+3 %_]). If this is not the case in user's implementation, then user will provide a correspondance method (see [6.2] and [7])
remark: it is expected that tile.bounds.length = 2*tile.neighbors.length
remark: this takes into account rounding error in coordinates computation, up to a distance between two points (expected to be identical) less than:
in order to fill the second par of the Map: 'type' -> Array of neighbors.length Arrays of four indices (these latter corresponding to bounds)default one: tile.neighbors[i] corresponds to segment (tile.bounds[2i],tile.bounds[2i+1]) -- (tile.bounds[2i+2 %_],tile.bounds[2i+3 %_]) may be constructed via the method below, as it depends on input:
- number of neighbors
input:
- Array of tiles
- Map of tiles (idkey -> tile)
- neighbors2bounds (n2b) is a Map tile 'type' -> Array of neighbors.length Arrays of four indices output:
- number of matching segments founds
at this point the user writes its Tiling.mytiling function:
- define a base tiling
- call substitute
- return a Tiling
Tiling.mytiling = function({iterations}={}){
var tiles = []; etc tiles.push(mytile1); etc
remark: use the base tiles from step [1] and myclone() method, do not forget to fill neighbors for tiles of the base tiling and leave the boundary as 'undefined'
- tiles = substitute(...);
input:
- number of iterations
- Array of tiles (aka base tiling)
- scaling ratio of the substitution
- mysubstitution (see [2])
- mydupinfos (see [3])
- myneighbors (see [4])
- (optional) whether to call findNeighbors (see [6]), one of:
- false
- neighbors2bounds how it work? see the code below
- (optional) a tile type to initial sand content for decoration purpose, one of:
- false
- a Map tile type (tile.id[0]) -> number
- return new Tiling(tiles);
}
return the new coordinates for point A
return the new coordinates for point A
return the new coordinates for point A caution: a positive = counterclockwise a negative = clockwise