Shape

Draw basic polygon-type shapes

Author
  • Mark Mayes / mm-dev
License
  • GPL-3.0-only
Source

Methods

(static) defaultStrokeCurrentPath()

Source
Add a stroke/outline to a shape

The stroke is coloured as a translucent version of the background colour of the current level

(static) drawCircle(_x, _y, _data)

Source
Draw a basic gradient-filled circle
Parameters
Name Type Description
_x number

X coordinate to draw at

_y number

Y coordinate to draw at

_data object

Other details

(static) drawEllipse(_x, _y, _radius, _color, _stretch, _angleDegrees)

Source
Draw an ellipse
Parameters
Name Type Description
_x number
_y number
_radius number
_color string
_stretch number
_angleDegrees number

(static) drawFlower(_x, _y, _obstacle)

Source
Draw a star shape
Parameters
Name Type Description
_x number
_y number
_obstacle object
Name Type Description
numAppendages number

Number of petals of the flower

shapeCenterColor number

Colour to use for the flower centre

shapeCenterRadiusDivisor number

Size of the central fill based on the radius of the obstacle

useDefaultStroke boolean

If true add the standard stroke around the shape

(static) drawSquarcle(_x, _y, _obstacle)

Source
Draw a combined square and circle
  • Used eg for bullets, ghosts
Parameters
Name Type Description
_x number
_y number
_obstacle object

(static) drawStar(_x, _y, _obstacle)

Source
Draw a star shape
Parameters
Name Type Description
_x number
_y number
_obstacle object
Name Type Description
numAppendages number

Number of points of the star

shapeCenterRadiusDivisor number

Size of the central fill based on the radius of the obstacle

useDefaultStroke boolean

If true add the standard stroke around the shape

(static) getObstacleGradient(_x, _y, _obstacle) → {CanvasGradient}

Source
Draw a gradient based on obstacle properties
  • Matches size and rotation of the gradient to the obstacle
  • Uses defaults where properties aren't specified
Parameters
Name Type Description
_x number

X coordinate to draw at

_y number

Y coordinate to draw at

_obstacle object

The obstacle to get properties from

Name Type Description
gradient object

Details about the gradient to be applied

Name Type Description
stop_ar Array.<object>

Gradient stops in {pos, color} format

type GRADIENT_TYPE

Eg linear/radial

fadePoint number

Used to fade the default gradient out to the background colour of the current level (0 to 1 - 0 means fade from centre, 1 would be the outer edge so effectively no fade) j

Returns
  CanvasGradient

(static) updateSizes()

Source
Update the generic outer stroke thickness based on the current layout/viewport