CustomImage.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.ratio = 1;
  17. this.geoType = VectorType.CustomImage
  18. this.setId(vectorId)
  19. }
  20. isContain(position) {
  21. if(Math.abs(position.x - this.center.x)* coordinate.res * coordinate.zoom/ 100 <this.ratio*this.width/2 && Math.abs(position.y - this.center.y)* coordinate.res * coordinate.zoom/ 100<this.ratio*this.height/2)
  22. {
  23. return SelectState.Select
  24. } else {
  25. return null
  26. }
  27. }
  28. setImageData(imgData){
  29. this.image = imgData;
  30. }
  31. setUrl(url){
  32. this.url = url;
  33. }
  34. setAngle(angle){
  35. this.angle = angle;
  36. }
  37. setScale(scale){
  38. this.scale = scale;
  39. }
  40. setRatio(ratio){
  41. this.ratio = ratio;
  42. }
  43. }