|
@@ -1,76 +1,75 @@
|
|
|
-import VectorType from '../enum/VectorType.js'
|
|
|
-import Geometry from './Geometry'
|
|
|
-import { mathUtil } from '../MathUtil.js'
|
|
|
-import SelectState from '../enum/SelectState.js'
|
|
|
-import { coordinate } from '../Coordinate.js'
|
|
|
+import VectorType from "../enum/VectorType.js";
|
|
|
+import Geometry from "./Geometry";
|
|
|
+import { mathUtil } from "../MathUtil.js";
|
|
|
+import SelectState from "../enum/SelectState.js";
|
|
|
+import { coordinate } from "../Coordinate.js";
|
|
|
|
|
|
export default class BgImage extends Geometry {
|
|
|
- constructor(url,center,vectorId) {
|
|
|
- super()
|
|
|
- this.url = url;
|
|
|
- if(center){
|
|
|
- this.center = center //左上角
|
|
|
- }else{
|
|
|
- this.center = {
|
|
|
- x:80,
|
|
|
- y:150
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.image = null;
|
|
|
- this.width = 540;
|
|
|
- this.height = 390;
|
|
|
- this.scale = 1 //缩放比例
|
|
|
-
|
|
|
- this.geoType = VectorType.BgImage
|
|
|
- this.setId(vectorId)
|
|
|
+ constructor(url, center, vectorId) {
|
|
|
+ super();
|
|
|
+ this.url = url;
|
|
|
+ if (center) {
|
|
|
+ this.center = center; //左上角
|
|
|
+ } else {
|
|
|
+ this.center = {
|
|
|
+ x: 80,
|
|
|
+ y: 150,
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
- setImageData(imgData){
|
|
|
- this.image = imgData;
|
|
|
- }
|
|
|
+ this.image = null;
|
|
|
+ this.width = 540;
|
|
|
+ this.height = 390;
|
|
|
+ this.scale = 1; //缩放比例
|
|
|
|
|
|
- setUrl(url){
|
|
|
- this.url = url;
|
|
|
- }
|
|
|
+ this.geoType = VectorType.BgImage;
|
|
|
+ this.setId(vectorId);
|
|
|
+ }
|
|
|
|
|
|
- setScale(scale){
|
|
|
- this.scale = scale;
|
|
|
- }
|
|
|
+ setImageData(imgData) {
|
|
|
+ this.image = imgData;
|
|
|
+ }
|
|
|
+
|
|
|
+ setUrl(url) {
|
|
|
+ this.url = url;
|
|
|
+ }
|
|
|
+
|
|
|
+ setScale(scale) {
|
|
|
+ this.scale = scale;
|
|
|
+ }
|
|
|
|
|
|
- isContain(position) {
|
|
|
+ isContain(position) {
|
|
|
+ let p0 = {
|
|
|
+ x: this.center.x,
|
|
|
+ y: this.center.y,
|
|
|
+ };
|
|
|
|
|
|
- let p0 = {
|
|
|
- x:this.center.x,
|
|
|
- y:this.center.y
|
|
|
- }
|
|
|
+ let p1 = {
|
|
|
+ x: this.center.x,
|
|
|
+ y: this.center.y + this.height * this.scale,
|
|
|
+ };
|
|
|
|
|
|
- let p1 = {
|
|
|
- x:this.center.x,
|
|
|
- y:this.center.y + this.height*this.scale
|
|
|
- }
|
|
|
+ let p2 = {
|
|
|
+ x: this.center.x + this.width * this.scale,
|
|
|
+ y: this.center.y + this.height * this.scale,
|
|
|
+ };
|
|
|
|
|
|
- let p2 = {
|
|
|
- x:this.center.x + this.width*this.scale,
|
|
|
- y:this.center.y + this.height*this.scale
|
|
|
- }
|
|
|
+ let p3 = {
|
|
|
+ x: this.center.x + this.width * this.scale,
|
|
|
+ y: this.center.y,
|
|
|
+ };
|
|
|
|
|
|
- let p3 = {
|
|
|
- x:this.center.x + this.width*this.scale,
|
|
|
- y:this.center.y
|
|
|
- }
|
|
|
-
|
|
|
- position = coordinate.getScreenXY(position);
|
|
|
+ position = coordinate.getScreenXY(position);
|
|
|
|
|
|
- this.points = [];
|
|
|
- this.points.push(p0)
|
|
|
- this.points.push(p1)
|
|
|
- this.points.push(p2)
|
|
|
- this.points.push(p3)
|
|
|
- if(mathUtil.isPointInPoly(position, this.points)){
|
|
|
- return SelectState.Select
|
|
|
- }else {
|
|
|
- return null
|
|
|
- }
|
|
|
+ this.points = [];
|
|
|
+ this.points.push(p0);
|
|
|
+ this.points.push(p1);
|
|
|
+ this.points.push(p2);
|
|
|
+ this.points.push(p3);
|
|
|
+ if (mathUtil.isPointInPoly(position, this.points)) {
|
|
|
+ return SelectState.Select;
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
+}
|