Module gamejs/transform

Rotate and scale Surfaces.

Functions

  • flip(surface, flipHorizontal, flipVertical)
  • rotate(surface, angle)
  • scale(surface, dimensions)

flip (surface, flipHorizontal, flipVertical)

Flip a Surface either vertically, horizontally or both. This returns a new Surface (i.e: nondestructive).

Parameters

gamejs.Surface surface
Boolean flipHorizontal
Boolean flipVertical

Returns

Surface new, flipped surface

rotate (surface, angle)

Returns a new surface which holds the original surface rotate by angle degrees. Unless rotating by 90 degree increments, the image will be padded larger to hold the new size.

Parameters

Surface surface
angel angle Clockwise angle by which to rotate

Returns

Surface new, rotated surface

scale (surface, dimensions)

Returns a new surface holding the scaled surface.

Parameters

Surface surface
Array dimensions new [width, height] of surface after scaling

Returns

Surface new, scaled surface