1
0

Compass.js 876 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import VectorType from '../enum/VectorType.js'
  2. import Geometry from './Geometry'
  3. import { coordinate } from '../Coordinate'
  4. import { mathUtil } from '../MathUtil.js'
  5. export default class Compass extends Geometry {
  6. constructor(angle,vectorId, floor) {
  7. super()
  8. this.angle = angle?angle:0
  9. this.floor = floor?floor:0
  10. //固定位置
  11. this.center = {
  12. x:800,
  13. y:170
  14. }
  15. this.radius = 52 //svg的大小
  16. this.geoType = VectorType.Compass
  17. this.setId(vectorId)
  18. }
  19. setAngle(angle){
  20. this.angle = angle
  21. }
  22. isContain(position) {
  23. const point = coordinate.getScreenXY(position)
  24. const dis = mathUtil.getDistance(this.center,point)
  25. if(dis < this.radius){
  26. return true
  27. }
  28. else{
  29. return false;
  30. }
  31. }
  32. }