flip-y.js 636 B

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.flipY = void 0;
  4. const flipY = function (img) {
  5. // d d
  6. // q q
  7. const canvas = document.createElement('canvas');
  8. const width = img.width;
  9. const height = img.height;
  10. canvas.width = width;
  11. canvas.height = height * 2;
  12. const ctx = canvas.getContext('2d');
  13. // top image
  14. ctx.drawImage(img, 0, 0, width, height);
  15. // flipped bottom image
  16. ctx.translate(0, 2 * height);
  17. ctx.scale(1, -1);
  18. ctx.drawImage(img, 0, 0, width, height);
  19. return canvas;
  20. };
  21. exports.flipY = flipY;
  22. //# sourceMappingURL=flip-y.js.map