Img.js 811 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { mathUtil } from "../Util/MathUtil.js";
  2. import VectorType from "../enum/VectorType.js";
  3. import Geometry from "./Geometry";
  4. export default class Img extends Geometry {
  5. constructor(src, vectorId) {
  6. super();
  7. this.src = null;
  8. this.angle = 0;
  9. this.display = true;
  10. this.center = null;
  11. this.imageData = null;
  12. this.geoType = VectorType.Img;
  13. this.setId(vectorId);
  14. this.setSrc(src);
  15. }
  16. setAngle(value) {
  17. this.angle = value;
  18. }
  19. setSrc(src) {
  20. this.src = src;
  21. }
  22. setImageData() {
  23. return new Promise((resolve, reject) => {
  24. this.imageData = new Image();
  25. this.imageData.src = this.src;
  26. this.imageData.onload = function () {
  27. resolve();
  28. };
  29. this.imageData.onerror = function () {
  30. reject();
  31. };
  32. });
  33. }
  34. }