class HitCanvas

Keeps track of regions of interest (hit regions).

Hit regions are registered during the draw loop of the main visible canvas. A sticky identifier should be used to mark regions as meaning the same between different draws.

Properties
ctx
Methods
constructor, beginHitRegion, clear, createChild, drawRegions, getActiveRegion, getActiveRegions, getRegionsForProperty, transferTo

Properties

ctx
get
Type:
CanvasRenderingContext2D

Methods

constructor(parent?, width?, height?)
Parameters:
beginHitRegion(hitRegion)
Parameters:
Return type:
string
clear()
Return type:
void
createChild(width, height)
Parameters:
  • number width
  • number height
Return type:
HitCanvas
drawRegions(ctx, dx, dy)
Parameters:
  • CanvasRenderingContext2D ctx
  • number dx
  • number dy
Return type:
void
getActiveRegion(x, y, property?)

Returns the active region for a given coordinate. Regions are tried in bottom-up order.

Parameters:
  • number x –
  • number y –
  • K property –
Return type:
undefined | HitRegionSpecification
Type constraints:
getActiveRegions(x, y, property?)

Returns all active regions for a given coordinate.

Parameters:
  • number x –
  • number y –
  • K property –
Return type:
HitRegionSpecification[]
Type constraints:
getRegionsForProperty(property)
Parameters:
  • K property
Return type:
HitRegionSpecification[]
Type constraints:
transferTo(ctx, dx, dy, dw, dh)
Parameters:
  • CanvasRenderingContext2D ctx
  • number dx
  • number dy
  • number dw
  • number dh
Return type:
void