|
@@ -1,24 +1,25 @@
|
|
|
import VectorType from '../enum/VectorType.js'
|
|
|
import Geometry from './Geometry'
|
|
|
+import { mathUtil } from '../MathUtil.js'
|
|
|
+import SelectState from '../enum/SelectState.js'
|
|
|
|
|
|
export default class CustomImage extends Geometry {
|
|
|
- constructor(src,center,vectorId) {
|
|
|
+ constructor(url,center,vectorId) {
|
|
|
super()
|
|
|
this.center = center
|
|
|
- this.src = src;
|
|
|
+ this.url = url;
|
|
|
this.image = null;
|
|
|
this.width = 40;
|
|
|
this.height = 30;
|
|
|
this.angle = 0 //逆时针为负,顺时针为正。单位是:°
|
|
|
- this.scale = 1 //缩放比例
|
|
|
+ //this.scale = 1 //缩放比例
|
|
|
this.geoType = VectorType.CustomImage
|
|
|
this.setId(vectorId)
|
|
|
}
|
|
|
|
|
|
isContain(position) {
|
|
|
- const dis = mathUtil.getDistance(position, this.center)
|
|
|
- let len = this.getLen() * this.scale
|
|
|
- if (dis < len / 2) {
|
|
|
+ if(Math.abs(position.x - this.center.x)<this.width/2 && Math.abs(position.y - this.center.y)<this.height/2)
|
|
|
+ {
|
|
|
return SelectState.Select
|
|
|
} else {
|
|
|
return null
|
|
@@ -29,7 +30,7 @@ export default class CustomImage extends Geometry {
|
|
|
this.image = imgData;
|
|
|
}
|
|
|
|
|
|
- setSrc(src){
|
|
|
- this.src = src;
|
|
|
+ setUrl(url){
|
|
|
+ this.url = url;
|
|
|
}
|
|
|
}
|