flip-y.js 519 B

123456789101112131415161718
  1. export const flipY = function (img) {
  2. // d d
  3. // q q
  4. const canvas = document.createElement('canvas');
  5. const width = img.width;
  6. const height = img.height;
  7. canvas.width = width;
  8. canvas.height = height * 2;
  9. const ctx = canvas.getContext('2d');
  10. // top image
  11. ctx.drawImage(img, 0, 0, width, height);
  12. // flipped bottom image
  13. ctx.translate(0, 2 * height);
  14. ctx.scale(1, -1);
  15. ctx.drawImage(img, 0, 0, width, height);
  16. return canvas;
  17. };
  18. //# sourceMappingURL=flip-y.js.map