Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

Properties

baseBounds

baseBounds: Bounds

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

name

baseBounds

member

{Bounds}

memberof

GirihTile

instance

Readonly className

className: string = "Polygon"

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

Readonly edgeLength

edgeLength: number

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

name

edgeLength

member

{number}

memberof

GirihTile

readonly
instance

innerTilePolygons

innerTilePolygons: Array<Polygon>

The inner tile polygons.

name

innerTilePolygons

member

{Array}

memberof

GirihTile

instance

isDestroyed

isDestroyed: boolean
member

isDestroyed

memberof

Polygon

instance

isOpen

isOpen: boolean
member

{boolean}

memberof

Polygon

instance

outerTilePolygons

outerTilePolygons: Array<Polygon>

The outer tile polygons.

name

outerTilePolygons

member

{Array}

memberof

GirihTile

instance

position

position: Vertex

The center of this tile.

name

position

member

{Vertex}

memberof

GirihTile

instance

rotation

rotation: number

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

name

rotation.

member

{number}

memberof

GirihTile

instance

symmetry

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

{number}

memberof

GirihTile

instance

Readonly textureSource

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

{Bounds}

memberof

GirihTile

instance

tileType

tileType: TileType

An identifier for the tile type.

name

tileType

member

{TileType}

memberof

GirihTile

instance

Readonly uid

uid: UID

The UID of this drawable object.

member

{UID}

memberof

Polygon

instance
readonly

uniqueSymmetries

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

{number}

memberof

GirihTile

instance

vertices

vertices: Array<Vertex>
member

{Array}

memberof

Polygon

instance

Static Readonly DEFAULT_EDGE_LENGTH

DEFAULT_EDGE_LENGTH: number = 58

The default edge length.

name

DEFAULT_EDGE_LENGTH

member

{number}

memberof

GirihTile

readonly
static

Static epsilon

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

{number}

memberof

GirihTile

static

Methods

Private _buildInnerPolygons

  • _buildInnerPolygons(edgeLength: number): void

Private _buildOuterPolygons

  • _buildOuterPolygons(edgeLength: number): void

addVertex

  • addVertex(vert: Vertex): void

area

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

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

    method

    area

    instance
    memberof

    Polygon

    Returns number

clone

closestLineIntersection

  • closestLineIntersection(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Vertex | null
  • 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.

    • Default value 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 | null

    • An array of all intersections within the polygon bounds.

containsPolygon

  • containsPolygon(polygon: Polygon): boolean
  • 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

containsVert

destroy

  • destroy(): void
  • 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

findAdjacentTilePosition

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

    name

    findAdjacentTilePosition

    memberof

    GirihTile

    instance

    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 | null

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

getBounds

getEvenDistributionPolygon

  • getEvenDistributionPolygon(pointCount: number): Polygon

getInnerTilePolygonAt

  • getInnerTilePolygonAt(index: number): Polygon

getInterpolationPolygon

  • getInterpolationPolygon(interpolationCount: number): Polygon
  • 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).

getOuterTilePolygonAt

  • getOuterTilePolygonAt(index: number): Polygon

getVertexAt

  • getVertexAt(index: number): Vertex
  • 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 )
    metho

    getVertexAt

    instance
    memberof

    Polygon

    Parameters

    • index: number

      The index of the desired vertex.

    Returns Vertex

    At the given index.

isClockwise

  • isClockwise(): boolean
  • Get the winding order of this polgon: clockwise or counterclockwise.

    method

    isClockwise

    instance
    memberof

    Polygon

    Returns boolean

lineIntersections

  • lineIntersections(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vertex>
  • 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.

    • Default value inVectorBoundsOnly: boolean = false

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

    Returns Array<Vertex>

    • An array of all intersections within the polygon bounds.

locateEdgeAtPoint

  • locateEdgeAtPoint(point: XYCoords, tolerance: number): number
  • 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?

    name

    locateEdgeAtPoint

    instance
    memberof

    GirihTile

    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.

move

perimeter

  • perimeter(): number
  • 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.

    method

    perimeter

    instance
    memberof

    Polygon

    Returns number

rotate

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

    name

    rotate

    instance
    memberof

    GirihTile

    Parameters

    • angle: number

      The angle to use for rotation.

    • Optional center: Vertex

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

    Returns GirihTile

    this

scale

  • Scale the polygon relative to the given center.

    method

    scale

    instance
    memberof

    Polygon

    Parameters

    • factor: number

      The scale factor.

    • center: Vertex

      The center of scaling.

    Returns Polygon

    this, for chaining.

signedArea

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

    method

    signedArea

    instance
    memberof

    Polygon

    Returns number

toCubicBezierData

  • toCubicBezierData(threshold: number | undefined): Array<Vertex>
  • 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
    method

    toCubicBezierData

    instance
    memberof

    Polygon

    Parameters

    • threshold: number | undefined

      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 Array<Vertex>

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

toCubicBezierPath

  • toCubicBezierPath(threshold: number): BezierPath
  • Convert this polygon to a cubic bezier path instance.

    method

    toCubicBezierPath

    instance
    memberof

    Polygon

    Parameters

    • threshold: number

      The threshold, usually from 0.0 to 1.0.

    Returns BezierPath

    • A bezier path instance.

toCubicBezierSVGString

  • toCubicBezierSVGString(threshold: number): string
  • Convert this polygon to a cubic bezier curve, represented as an SVG data string.

    method

    toCubicBezierSVGString

    instance
    memberof

    Polygon

    Parameters

    • threshold: number

    Returns string

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

toQuadraticBezierData

  • toQuadraticBezierData(): Array<Vertex>
  • 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
    method

    toQuadraticBezierData

    instance
    memberof

    Polygon

    Returns Array<Vertex>

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

toQuadraticBezierSVGString

  • toQuadraticBezierSVGString(): string
  • Convert this polygon to a quadratic bezier curve, represented as an SVG data string.

    method

    toQuadraticBezierSVGString

    instance
    memberof

    Polygon

    Returns string

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

transformTilePositionToAdjacency

  • transformTilePositionToAdjacency<P>(baseEdgeIndex: number, neighbourTile: P): P | null
  • Apply adjacent tile position to neighbourTile.

    name

    transformTilePositionToAdjacencies

    memberof

    GirihTile

    instance

    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 | null

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

transformTileToAdjacencies

  • transformTileToAdjacencies(baseEdgeIndex: number, neighbourTile: GirihTile): Array<GirihTile>
  • Find all possible adjacent tile positions (and rotations) for neighbourTile.

    name

    transformTileToAdjacencies

    memberof

    GirihTile

    instance

    Parameters

    • baseEdgeIndex: number

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

    • neighbourTile: GirihTile

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

    Returns Array<GirihTile>

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

Object literals

Static utils

utils: object

area

  • area(vertices: Array<XYCoords>): number
  • Calculate the area of the given polygon (unsigned).

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

    name

    area

    Parameters

    Returns number

signedArea

  • signedArea(vertices: Array<XYCoords>): number
  • Calulate the signed polyon area by interpreting the polygon as a matrix and calculating its determinant.

    name

    signedArea

    Parameters

    Returns number

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Private property
  • Private method
  • Static property
  • Static method

Generated using TypeDoc