| 32 | * @ignore |
| 33 | */ |
| 34 | export 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 |