|
@@ -121,23 +121,19 @@ export default class Draw {
|
|
|
}
|
|
|
|
|
|
drawBackGroundImg(vector) {
|
|
|
- help.getImage(vector.src)
|
|
|
- .then(img => {
|
|
|
- const width = help.getReal(img.width)
|
|
|
- const height = help.getReal(img.height)
|
|
|
- const center = coordinate.getScreenXY({x: 0, y: 0});
|
|
|
- this.context.save();
|
|
|
- this.context.drawImage(
|
|
|
- img,
|
|
|
- center.x - width / 2,
|
|
|
- center.y - height / 2,
|
|
|
- width,
|
|
|
- height
|
|
|
- )
|
|
|
- this.context.restore();
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
+ const img = vector.imageData
|
|
|
+ const width = help.getReal(img.width)
|
|
|
+ const height = help.getReal(img.height)
|
|
|
+ const center = coordinate.getScreenXY(vector.center);
|
|
|
+ this.context.save();
|
|
|
+ this.context.drawImage(
|
|
|
+ img,
|
|
|
+ center.x - width / 2,
|
|
|
+ center.y - height / 2,
|
|
|
+ width,
|
|
|
+ height
|
|
|
+ )
|
|
|
+ this.context.restore();
|
|
|
}
|
|
|
|
|
|
drawGrid(startX, startY, w, h, step1, step2) {
|
|
@@ -396,7 +392,7 @@ export default class Draw {
|
|
|
const ctx = this.context
|
|
|
|
|
|
const ange = 30
|
|
|
- const L = 8;
|
|
|
+ const L = 20;
|
|
|
let a = Math.atan2((end.y - start.y), (end.x - start.x));
|
|
|
let xC = end.x - L * Math.cos(a + ange * Math.PI/180); // θ=30
|
|
|
let yC = end.y - L * Math.sin(a + ange * Math.PI/180);
|
|
@@ -462,29 +458,41 @@ export default class Draw {
|
|
|
ctx.lineTo(targetPts[1].x, targetPts[1].y)
|
|
|
ctx.stroke();
|
|
|
|
|
|
- imgCache[Object.keys(imgCache)[0]].then(img => {
|
|
|
- const size = help.getReal(style.target.radius);
|
|
|
- ctx.save();
|
|
|
- ctx.beginPath()
|
|
|
- ctx.arc(target.x, target.y, size, 0, 2*Math.PI);
|
|
|
- ctx.clip()
|
|
|
- ctx.drawImage(
|
|
|
- img,
|
|
|
- vector.position.x - style.target.radius,
|
|
|
- vector.position.y - style.target.radius,
|
|
|
- style.target.radius*2,
|
|
|
- style.target.radius*2,
|
|
|
- target.x - size,
|
|
|
- target.y - size,
|
|
|
- size*2,
|
|
|
- size*2
|
|
|
- );
|
|
|
- ctx.strokeStyle = style.target.strokeStyle
|
|
|
- ctx.lineWidth = style.target.lineWidth
|
|
|
- ctx.stroke()
|
|
|
- ctx.restore();
|
|
|
- })
|
|
|
-
|
|
|
+ let img, imgBound
|
|
|
+ if (vector.photoImage) {
|
|
|
+ img = vector.photoImage
|
|
|
+ imgBound = [0, 0, img.width, img.height]
|
|
|
+ } else {
|
|
|
+ const size = style.target.realRadius
|
|
|
+ const backImg = dataService.getBackgroundImg()
|
|
|
+ img = backImg.imageData
|
|
|
+ const imgCenter = coordinate.getScreenXY(backImg.center)
|
|
|
+ const start = {
|
|
|
+ x: imgCenter.x - img.width / 2,
|
|
|
+ y: imgCenter.y - img.height / 2
|
|
|
+ }
|
|
|
+ imgBound = [
|
|
|
+ pt.x - start.x - size,
|
|
|
+ pt.y - start.y - size,
|
|
|
+ size * 2,
|
|
|
+ size * 2
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ const size = help.getReal(style.target.radius);
|
|
|
+ ctx.beginPath()
|
|
|
+ ctx.arc(target.x, target.y, size, 0, 2*Math.PI);
|
|
|
+ ctx.clip()
|
|
|
+ ctx.drawImage(
|
|
|
+ img,
|
|
|
+ ...imgBound,
|
|
|
+ target.x - size,
|
|
|
+ target.y - size,
|
|
|
+ size*2,
|
|
|
+ size*2
|
|
|
+ );
|
|
|
+ ctx.strokeStyle = style.target.strokeStyle
|
|
|
+ ctx.lineWidth = style.target.lineWidth
|
|
|
+ ctx.stroke()
|
|
|
}
|
|
|
ctx.restore();
|
|
|
}
|
|
@@ -496,7 +504,7 @@ export default class Draw {
|
|
|
...element.center
|
|
|
});
|
|
|
|
|
|
- console.log(element)
|
|
|
+ element.points.forEach(point => this.drawPoint(point))
|
|
|
}
|
|
|
|
|
|
drawPoint(vector) {
|