|
@@ -578,8 +578,22 @@ export default class Draw {
|
|
this.context.font = oldFont;
|
|
this.context.font = oldFont;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ drawLineText(vector) {
|
|
|
|
+ const startReal = dataService.getPoint(vector.startId);
|
|
|
|
+ const start = coordinate.getScreenXY(startReal);
|
|
|
|
+ const endReal = dataService.getPoint(vector.endId);
|
|
|
|
+ const end = coordinate.getScreenXY(endReal);
|
|
|
|
+
|
|
|
|
+ const angle = Math.atan2(end.y - start.y, end.x - start.x) * 180 / Math.PI;
|
|
|
|
+ this.context.translate(start.x, start.y);
|
|
|
|
+ this.context.rotate(angle * Math.PI / 180);
|
|
|
|
+
|
|
|
|
+// 在路径上绘制文本
|
|
|
|
+ context.fillText('Hello World!', 0, 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
drawLine(vector) {
|
|
drawLine(vector) {
|
|
- if ([UIEvents.Arrow, UIEvents.MeasureLine].includes(vector.category)) {
|
|
|
|
|
|
+ if ([UIEvents.Arrow, UIEvents.MeasureFree].includes(vector.category)) {
|
|
return this.drawArrow(vector);
|
|
return this.drawArrow(vector);
|
|
}
|
|
}
|
|
const startReal = dataService.getPoint(vector.startId);
|
|
const startReal = dataService.getPoint(vector.startId);
|
|
@@ -596,7 +610,7 @@ export default class Draw {
|
|
if (style.dash) {
|
|
if (style.dash) {
|
|
this.context.setLineDash(style.dash);
|
|
this.context.setLineDash(style.dash);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
this.context.beginPath();
|
|
this.context.beginPath();
|
|
this.context.moveTo(start.x, start.y);
|
|
this.context.moveTo(start.x, start.y);
|
|
this.context.lineTo(end.x, end.y);
|
|
this.context.lineTo(end.x, end.y);
|