MCPcopy Create free account
hub / github.com/melonjs/melonJS / buildFlipTransform

Function buildFlipTransform

packages/melonjs/src/level/tiled/TMXTile.js:34–55  ·  view source on GitHub ↗
(transform, flipMask, width, height)

Source from the content-addressed store, hash-verified

32 * @ignore
33 */
34export function buildFlipTransform(transform, flipMask, width, height) {
35 const halfW = width / 2;
36 const halfH = height / 2;
37 const flippedH = (flipMask & FLIP_H_BIT) !== 0;
38 const flippedV = (flipMask & FLIP_V_BIT) !== 0;
39 const flippedAD = (flipMask & FLIP_AD_BIT) !== 0;
40
41 transform.identity();
42 transform.translate(halfW, halfH);
43 if (flippedAD) {
44 transform.rotate(degToRad(-90));
45 transform.scale(-1, 1);
46 }
47 if (flippedH) {
48 transform.scale(flippedAD ? 1 : -1, flippedAD ? -1 : 1);
49 }
50 if (flippedV) {
51 transform.scale(flippedAD ? -1 : 1, flippedAD ? 1 : -1);
52 }
53 transform.translate(-halfW, -halfH);
54 return transform;
55}
56
57/**
58 * a basic tile object

Callers 1

drawTileRawMethod · 0.90

Calls 5

degToRadFunction · 0.90
identityMethod · 0.45
translateMethod · 0.45
rotateMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected