CustomImage.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import VectorType from '../enum/VectorType.js'
  2. import Geometry from './Geometry'
  3. import { mathUtil } from '../MathUtil.js'
  4. import SelectState from '../enum/SelectState.js'
  5. import { coordinate } from '../Coordinate'
  6. export default class CustomImage extends Geometry {
  7. constructor(url,center,vectorId) {
  8. super()
  9. this.center = center
  10. this.url = url;
  11. this.image = null;
  12. this.width = 40;
  13. this.height = 30;
  14. this.angle = 0 //逆时针为负,顺时针为正。单位是:°
  15. this.scale = 1 //缩放比例
  16. this.geoType = VectorType.CustomImage
  17. this.setId(vectorId)
  18. }
  19. isContain(position) {
  20. if(Math.abs(position.x - this.center.x)* coordinate.res * coordinate.zoom/ 100 <this.width/2 && Math.abs(position.y - this.center.y)* coordinate.res * coordinate.zoom/ 100<this.height/2)
  21. {
  22. return SelectState.Select
  23. } else {
  24. return null
  25. }
  26. }
  27. setImageData(imgData){
  28. this.image = imgData;
  29. }
  30. setUrl(url){
  31. this.url = url;
  32. }
  33. setAngle(angle){
  34. this.angle = angle;
  35. }
  36. setScale(scale){
  37. this.scale = scale;
  38. }
  39. }