Optional
edgeLength: numberGirihHexagon
The initial bounds (of the un-rotated tile). These are required to calculate the correct texture mapping.
baseBounds
GirihTile
Readonly
classRequired to generate proper CSS classes and other class related IDs.
Readonly
edgeThe edge length of this tile (all edges of a Girih tile have same length).
edgeLength
GirihTile
The inner tile polygons.
innerTilePolygons
GirihTile
isDestroyed
Polygon
Polygon
The outer tile polygons.
outerTilePolygons
GirihTile
The center of this tile.
position
GirihTile
The rotation of this tile. This is stored to make cloning easier.
rotation.
GirihTile
The symmetry (=order) of this tile. This is the number of steps used for a full rotation (in this Girih case: 10). Future Girih implementations might have other symmetries.
symmetry
GirihTile
Readonly
textureA rectangle on the shipped texture image (girihtexture-500px.png
) marking the
texture position. The bounds are relative, so each component must be in [0..1].
The texture is a square.
textureSource
GirihTile
An identifier for the tile type.
tileType
GirihTile
Readonly
uidThe UID of this drawable object.
Polygon
The unique symmetries. This must be an nth part of the global symmetry
.
Rotating this tile `uniqueSymmetries' times results in the same visual tile (flipped around
a symmetry axis).
uniqueSymmetries
GirihTile
Polygon
Static
Readonly
DEFAULT_The default edge length.
DEFAULT_EDGE_LENGTH
GirihTile
Static
epsilonAn epsilon to use for detecting adjacent edges. 0.001 seems to be a good value. Adjust if needed.
epsilon
GirihTile
Static
utilsCalculate the area of the given polygon (unsigned).
Note that this does not work for self-intersecting polygons.
area
Calulate the signed polyon area by interpreting the polygon as a matrix and calculating its determinant.
signedArea
Private
_buildPrivate
_buildAdd a vertex to the end of the vertices
array.
The vertex to add.
addVertex
Polygon
Add a vertex at a particular position of the vertices
array.
The vertex to add.
The position to add the vertex at. Will be handled modulo.
addVertexAt
Polygon
Get the closest line-polygon-intersection point (closest the line point A).
See demo 47-closest-vector-projection-on-polygon
for how it works.
The line to find intersections with.
If set to true only intersecion points on the passed vector are considered (located strictly between start and end vertex).
Check if the passed polygon is completly contained inside this polygon.
This means:
The polygon to check if contained.
Check if the given vertex is inside this polygon.
Ray-casting algorithm found at
https://stackoverflow.com/questions/22521982/check-if-point-inside-a-polygon
The vertex to check. The new x-component.
True if the passed vertex is inside this polygon. The polygon is considered closed.
containsVert
Polygon
Find the adjacent tile (given by the template tile) Note that the tile itself will be modified (rotated and moved to the correct position).
The edge number of the you you want to find adjacency for.
The polygon (or tile) you want to find adjacency for at the specified edge.
Adjacency information or null if the passed tile does not match.
findAdjacentTilePosition
GirihTile
Construct a new polygon from this polygon with more vertices on each edge. The
interpolation count determines the number of additional vertices on each edge.
An interpolation count of 0
will return a polygon that equals the source
polygon.
A polygon with interpolationCount
more vertices (as as factor).
Get the polygon vertex at the given position (index).
The index may exceed the total vertex count, and will be wrapped around then (modulo).
For k >= 0:
The index of the desired vertex.
At the given index.
getVertexAt
Polygon
Get all line intersections with this polygon.
See demo 47-closest-vector-projection-on-polygon
for how it works.
The line to find intersections with.
If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).
This function locates the closest tile edge (polygon edge) to the passed point.
Currently the edge distance to a point is measured by the euclidian distance from the edge's middle point.
Idea: move this function to Polygon?
The point to detect the closest edge for.
The tolerance (=max distance) the detected edge must be inside.
the edge index (index of the starting vertex, so [index,index+1] is the edge ) or -1 if not found.
locateEdgeAtPoint
GirihTile
Rotate this tile Note: this function behaves a bitdifferent than the genuine Polygon.rotate function! Polygon has the default center of rotation at (0,0). The GirihTile rotates around its center (position) by default.
The angle to use for rotation.
Optional
center: VertexThe center of rotation (default is this.position).
this
rotate
GirihTile
Convert this polygon to a sequence of cubic Bézier curves.
The first vertex in the returned array is the start point.
The following sequence are triplets of (first-control-point, secnond-control-point, end-point):
startPoint, controlPoint0_0, controlPoint1_1, pathPoint1, controlPoint1_0, controlPoint1_1, ..., endPoint
An optional threshold (default=1.0) how strong the curve segments should over-/under-drive. Should be between 0.0 and 1.0 for best results but other values are allowed.
An array of 2d vertices that shape the cubic Bézier curve.
toCubicBezierData
Polygon
Convert this polygon to a cubic bezier path instance.
The threshold, usually from 0.0 to 1.0.
toCubicBezierPath
Polygon
Convert this polygon to a sequence of quadratic Bézier curves.
The first vertex in the returned array is the start point.
The following sequence are pairs of control-point-and-end-point:
startPoint, controlPoint0, pathPoint1, controlPoint1, pathPoint2, controlPoint2, ..., endPoint
An array of 2d vertices that shape the quadratic Bézier curve.
toQuadraticBezierData
Polygon
Apply adjacent tile position to neighbourTile
.
The edge number of the you you want to apply adjacent position for.
The polygon (or tile) you want to find adjacency for at the specified edge.
the passed tile itself if adjacency was found, null otherwise.
transformTilePositionToAdjacencies
GirihTile
Find all possible adjacent tile positions (and rotations) for neighbourTile
.
The edge number of the you you want to find adjacencies for.
The polygon (or tile) you want to find adjacencies for at the specified edge.
Adjacency information or null if the passed tile does not match.
transformTileToAdjacencies
GirihTile
Classdesc
This is a general tile superclass. All other tile classes extends this one.
Rule:
Requires
Bounds
Requires
Polyon
Requires
Vertex
Requires
XYCoords