Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Heax

Hierarchy

  • Heax

Index

Constructors

constructor

  • new Heax(canvas?: HTMLCanvasElement): Heax
  • Parameters

    • canvas: HTMLCanvasElement = ...

      Canvas element

    Returns Heax

Properties

bounce

bounce: number = 0.9

canvas

canvas: HTMLCanvasElement

composites

composites: Composite[] = []

ctx

ctx: CanvasRenderingContext2D

friction

friction: number = 0.999

gravity

gravity: Vector = ...

groundFriction

groundFriction: number = 0.95

height

height: number

mouse

mouse: Mouse

width

width: number

Methods

clear

createCloth

  • createCloth(x?: number, y?: number, width?: number, height?: number, segments?: number, offset?: number, particleInfo: any, constraintInfo: any): Composite
  • Create a cloth

    example
    const cloth = heax.createCloth(0, 0, 250, 250, 9, 2, { color: "red" }, { width: 5 })
    

    Parameters

    • x: number = 0

      Top left x coordinate

    • y: number = 0

      Top left y coordinate

    • width: number = 250

      Width of cloth

    • height: number = 250

      Height of cloth

    • segments: number = 9

      No of segments

    • offset: number = 2

      Pin offset

    • particleInfo: any

      Particle info

    • constraintInfo: any

      Constraint info

    Returns Composite

createRectangle

  • createRectangle(x?: number, y?: number, w?: number, h?: number, particleInfo: any, constraintInfo: any): Composite
  • Create a reactangle

    example
    const reactangle = heax.createReactangle(0, 0, 100, 100, { color: "red" }, { width: 2 })
    

    Parameters

    • x: number = 0

      Top left x coordinate

    • y: number = 0

      Top left y coordinate

    • w: number = 100

      Width of box

    • h: number = 100

      Height of box

    • particleInfo: any

      Particle info

    • constraintInfo: any

      Constraint info

    Returns Composite

createRope

  • createRope(positionFunction?: (index: number) => { x: number; y: number }, segments?: number, particleInfo: any, constraintInfo: any): Composite
  • Create a rope

    example
    const fn = i => ({ x: 100 + i * 15, y: 100 + i * 15 })
    const rope = heax.createRope(fn, 15, { color: "red" }, { width: 10 })

    Parameters

    • positionFunction: (index: number) => { x: number; y: number } = ...

      Function which returns x and y coordinate of each points based on indexes

        • (index: number): { x: number; y: number }
        • Parameters

          • index: number

          Returns { x: number; y: number }

          • x: number
          • y: number
    • segments: number = 15

      No of segments

    • particleInfo: any

      Particle info

    • constraintInfo: any

      Constraint info

    Returns Composite

render

update

  • update(constraintBasedOnDimensionOfCanvas?: boolean): Heax
  • Update all composites

    Parameters

    • Optional constraintBasedOnDimensionOfCanvas: boolean

    Returns Heax

Generated using TypeDoc