Classdesc

This is a general tile superclass. All other tile classes extends this one.

Rule:

  • the outer and the inner sub polygons must be inside the main polygon's bounds.

Requires

Bounds

Requires

Polyon

Requires

Vertex

Requires

XYCoords

Hierarchy (view full)

Constructors

Properties

baseBounds: Bounds

The initial bounds (of the un-rotated tile). These are required to calculate the correct texture mapping.

Name

baseBounds

Member

Memberof

GirihTile

Instance

className: string = "Polygon"

Required to generate proper CSS classes and other class related IDs.

edgeLength: number

The edge length of this tile (all edges of a Girih tile have same length).

Name

edgeLength

Member

Memberof

GirihTile

Instance

innerTilePolygons: Polygon[]

The inner tile polygons.

Name

innerTilePolygons

Member

Memberof

GirihTile

Instance

isDestroyed: boolean

Member

isDestroyed

Memberof

Polygon

Instance

isOpen: boolean

Member

Memberof

Polygon

Instance

outerTilePolygons: Polygon[]

The outer tile polygons.

Name

outerTilePolygons

Member

Memberof

GirihTile

Instance

position: Vertex

The center of this tile.

Name

position

Member

Memberof

GirihTile

Instance

rotation: number

The rotation of this tile. This is stored to make cloning easier.

Name

rotation.

Member

Memberof

GirihTile

Instance

symmetry: number

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.

Name

symmetry

Member

Memberof

GirihTile

Instance

textureSource: Bounds

A 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.

Name

textureSource

Member

Memberof

GirihTile

Instance

tileType: TileType

An identifier for the tile type.

Name

tileType

Member

Memberof

GirihTile

Instance

uid: string

The UID of this drawable object.

Member

Memberof

Polygon

Instance

uniqueSymmetries: number

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).

Name

uniqueSymmetries

Member

Memberof

GirihTile

Instance

vertices: Vertex[]

Member

Memberof

Polygon

Instance

DEFAULT_EDGE_LENGTH: number = 58

The default edge length.

Name

DEFAULT_EDGE_LENGTH

Member

Memberof

GirihTile

Static

epsilon: number = 0.001

An epsilon to use for detecting adjacent edges. 0.001 seems to be a good value. Adjust if needed.

Name

epsilon

Member

Memberof

GirihTile

Static

utils: {
    area(vertices): number;
    signedArea(vertices): number;
} = ...

Type declaration

  • area:function
    • Calculate the area of the given polygon (unsigned).

      Note that this does not work for self-intersecting polygons.

      Parameters

      Returns number

      Name

      area

  • signedArea:function
    • Calulate the signed polyon area by interpreting the polygon as a matrix and calculating its determinant.

      Parameters

      Returns number

      Name

      signedArea

Methods

  • Add a vertex at a particular position of the vertices array.

    Parameters

    • vert: Vertex

      The vertex to add.

    • index: number

      The position to add the vertex at. Will be handled modulo.

    Returns void

    Method

    addVertexAt

    Instance

    Memberof

    Polygon

  • Calculate the area of the given polygon (unsigned).

    Note that this does not work for self-intersecting polygons.

    Returns number

    Method

    area

    Instance

    Memberof

    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.

    Parameters

    • line: VertTuple<any>

      The line to find intersections with.

    • inVectorBoundsOnly: boolean = false

      If set to true only intersecion points on the passed vector are considered (located strictly between start and end vertex).

    Returns Vertex

    • An array of all intersections within the polygon bounds.
  • Check if the passed polygon is completly contained inside this polygon.

    This means:

    • all polygon's vertices must be inside this polygon.
    • the polygon has no edge intersections with this polygon.

    Parameters

    • polygon: Polygon

      The polygon to check if contained.

    Returns boolean

  • This function should invalidate any installed listeners and invalidate this object. After calling this function the object might not hold valid data any more and should not be used.

    Returns void

  • Find the adjacent tile (given by the template tile) Note that the tile itself will be modified (rotated and moved to the correct position).

    Parameters

    • edgeIndex: number

      The edge number of the you you want to find adjacency for.

    • tile: Polygon

      The polygon (or tile) you want to find adjacency for at the specified edge.

    Returns IAdjacency

    Adjacency information or null if the passed tile does not match.

    Name

    findAdjacentTilePosition

    Memberof

    GirihTile

    Instance

  • 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.

    Parameters

    • interpolationCount: number

    Returns 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:

    • getVertexAt( vertices.length ) == getVertexAt( 0 )
    • getVertexAt( vertices.length + k ) == getVertexAt( k )
    • getVertexAt( -k ) == getVertexAt( vertices.length -k )

    Parameters

    • index: number

      The index of the desired vertex.

    Returns Vertex

    At the given index.

    Metho

    getVertexAt

    Instance

    Memberof

    Polygon

  • Get all line intersections with this polygon.

    See demo 47-closest-vector-projection-on-polygon for how it works.

    Parameters

    • line: VertTuple<any>

      The line to find intersections with.

    • inVectorBoundsOnly: boolean = false

      If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).

    Returns Vertex[]

    • An array of all intersections within the polygon bounds.
  • 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?

    Parameters

    • point: XYCoords

      The point to detect the closest edge for.

    • tolerance: number

      The tolerance (=max distance) the detected edge must be inside.

    Returns number

    the edge index (index of the starting vertex, so [index,index+1] is the edge ) or -1 if not found.

    Name

    locateEdgeAtPoint

    Instance

    Memberof

    GirihTile

  • Get the perimeter of this polygon. The perimeter is the absolute length of the outline.

    If this polygon is open then the last segment (connecting the first and the last vertex) will be skipped.

    Returns number

    Method

    perimeter

    Instance

    Memberof

    Polygon

  • 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.

    Parameters

    • angle: number

      The angle to use for rotation.

    • Optional center: Vertex

      The center of rotation (default is this.position).

    Returns GirihTile

    this

    Name

    rotate

    Instance

    Memberof

    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

    Parameters

    • threshold: number

      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.

    Returns Vertex[]

    An array of 2d vertices that shape the cubic Bézier curve.

    Method

    toCubicBezierData

    Instance

    Memberof

    Polygon

  • Convert this polygon to a cubic bezier curve, represented as an SVG data string.

    Parameters

    • threshold: number

    Returns string

    The 'd' part for an SVG 'path' element.

    Method

    toCubicBezierSVGString

    Instance

    Memberof

    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

    Returns Vertex[]

    An array of 2d vertices that shape the quadratic Bézier curve.

    Method

    toQuadraticBezierData

    Instance

    Memberof

    Polygon

  • Apply adjacent tile position to neighbourTile.

    Type Parameters

    Parameters

    • baseEdgeIndex: number

      The edge number of the you you want to apply adjacent position for.

    • neighbourTile: P

      The polygon (or tile) you want to find adjacency for at the specified edge.

    Returns P

    the passed tile itself if adjacency was found, null otherwise.

    Name

    transformTilePositionToAdjacencies

    Memberof

    GirihTile

    Instance