Skip to content

ArrowShape

Overview

An arrow shape, either single or double headed. ArrowShape has an optimization that allows you to reuse an array of Vector2. The array will have 0 points if the tail and tip are the same point.

@author John Blanco @author Chris Malley (PixelZoom, Inc.) @author Aaron Davis @author Sam Reid (PhET Interactive Simulations)

Class ArrowShape

import { ArrowShape } from 'scenerystack/scenery-phet';

Constructor

new ArrowShape( tailX : number, tailY : number, tipX : number, tipY : number, providedOptions : ArrowShapeOptions )

Instance Methods

Static Methods

getArrowShapePoints( tailX : number, tailY : number, tipX : number, tipY : number, shapePoints : Vector2[], providedOptions? : ArrowShapeOptions ) : Vector2[]

This method is static so it can be used in ArrowShape as well as in ArrowNode. If the tail and tip are at the same position, there are no points and the arrow will not be shown. @param tailX @param tailY @param tipX @param tipY @param shapePoints - if provided, values will be overwritten. This is to achieve high performance and is used by ArrowNode to avoid re-creating shapes. Tested this implementation vs the old one by creating hundreds of arrows and saw significant performance gains. @param providedOptions

Type ArrowShapeOptions

import type { ArrowShapeOptions } from 'scenerystack/scenery-phet';
  • tailWidth?: number
  • headWidth?: number
  • headHeight?: number
  • fractionalHeadHeight?: number
  • doubleHead?: boolean
  • isHeadDynamic?: boolean
  • scaleTailToo?: boolean

Source Code

See the source for ArrowShape.ts in the scenery-phet repository.