|
@@ -26,6 +26,7 @@ const help = {
|
|
];
|
|
];
|
|
let currentAttr;
|
|
let currentAttr;
|
|
|
|
|
|
|
|
+ //console.log(itemsEntry)
|
|
return [
|
|
return [
|
|
itemsEntry.reduce((prev, [item, attr]) => {
|
|
itemsEntry.reduce((prev, [item, attr]) => {
|
|
if (!item) return prev;
|
|
if (!item) return prev;
|
|
@@ -101,7 +102,7 @@ const help = {
|
|
for (const curve of coves) {
|
|
for (const curve of coves) {
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
ctx.moveTo(curve.start.x, curve.start.y);
|
|
ctx.moveTo(curve.start.x, curve.start.y);
|
|
- help.drawCove(ctx, curve)
|
|
|
|
|
|
+ help.drawCove(ctx, curve);
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -146,7 +147,9 @@ const help = {
|
|
},
|
|
},
|
|
getRealDistance(p1, p2) {
|
|
getRealDistance(p1, p2) {
|
|
return (
|
|
return (
|
|
- Math.round((mathUtil.getDistance(p1, p2) * coordinate.res * 100) / coordinate.ratio) / 100
|
|
|
|
|
|
+ Math.round(
|
|
|
|
+ (mathUtil.getDistance(p1, p2) * coordinate.res * 100) / coordinate.ratio
|
|
|
|
+ ) / 100
|
|
);
|
|
);
|
|
},
|
|
},
|
|
getPerpendicularPoint(p1, p2, p3, d) {
|
|
getPerpendicularPoint(p1, p2, p3, d) {
|
|
@@ -206,47 +209,72 @@ const help = {
|
|
ctx.restore();
|
|
ctx.restore();
|
|
},
|
|
},
|
|
isTriangleClockwise(p1, p2, p3) {
|
|
isTriangleClockwise(p1, p2, p3) {
|
|
- const crossProduct = (p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y);
|
|
|
|
|
|
+ const crossProduct =
|
|
|
|
+ (p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y);
|
|
return crossProduct < 0;
|
|
return crossProduct < 0;
|
|
},
|
|
},
|
|
- drawStyleLine(ctx, line, style = VectorStyle.SingleSolidLine, weight = VectorStyle.Thinning) {
|
|
|
|
|
|
+ drawStyleLine(
|
|
|
|
+ ctx,
|
|
|
|
+ line,
|
|
|
|
+ style = VectorStyle.SingleSolidLine,
|
|
|
|
+ weight = VectorStyle.Thinning
|
|
|
|
+ ) {
|
|
ctx.save();
|
|
ctx.save();
|
|
- style = style || VectorStyle.SingleSolidLine
|
|
|
|
|
|
+ style = style || VectorStyle.SingleSolidLine;
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
- const lineWidth = Settings.lineWidth * (ctx.lineWidth || 1) * (weight === VectorWeight.Bold ? 2 : 1);
|
|
|
|
|
|
+ const lineWidth =
|
|
|
|
+ Settings.lineWidth *
|
|
|
|
+ (ctx.lineWidth || 1) *
|
|
|
|
+ (weight === VectorWeight.Bold ? 2 : 1);
|
|
|
|
|
|
switch (style) {
|
|
switch (style) {
|
|
case VectorStyle.PointDrawLine:
|
|
case VectorStyle.PointDrawLine:
|
|
case VectorStyle.SingleDashedLine:
|
|
case VectorStyle.SingleDashedLine:
|
|
case VectorStyle.SingleSolidLine:
|
|
case VectorStyle.SingleSolidLine:
|
|
- ctx.lineWidth = lineWidth
|
|
|
|
|
|
+ ctx.lineWidth = lineWidth;
|
|
if (style === VectorStyle.SingleDashedLine) {
|
|
if (style === VectorStyle.SingleDashedLine) {
|
|
ctx.setLineDash([8 * coordinate.ratio, 8 * coordinate.ratio]);
|
|
ctx.setLineDash([8 * coordinate.ratio, 8 * coordinate.ratio]);
|
|
} else if (style === VectorStyle.PointDrawLine) {
|
|
} else if (style === VectorStyle.PointDrawLine) {
|
|
- ctx.setLineDash([6 * coordinate.ratio, 6* coordinate.ratio, 2 * coordinate.ratio]);
|
|
|
|
|
|
+ ctx.setLineDash([
|
|
|
|
+ 6 * coordinate.ratio,
|
|
|
|
+ 6 * coordinate.ratio,
|
|
|
|
+ 2 * coordinate.ratio,
|
|
|
|
+ ]);
|
|
}
|
|
}
|
|
|
|
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
- break
|
|
|
|
- // 单实线
|
|
|
|
|
|
+ break;
|
|
|
|
+ // 单实线
|
|
case VectorStyle.DoubleDashedLine:
|
|
case VectorStyle.DoubleDashedLine:
|
|
case VectorStyle.DoubleSolidLine:
|
|
case VectorStyle.DoubleSolidLine:
|
|
if (style === VectorStyle.DoubleDashedLine) {
|
|
if (style === VectorStyle.DoubleDashedLine) {
|
|
ctx.setLineDash([8 * coordinate.ratio, 8 * coordinate.ratio]);
|
|
ctx.setLineDash([8 * coordinate.ratio, 8 * coordinate.ratio]);
|
|
}
|
|
}
|
|
const pd1 = help.getPerpendicularPoint(
|
|
const pd1 = help.getPerpendicularPoint(
|
|
- line[0], line[1], line[0], 4 * coordinate.ratio,
|
|
|
|
- )
|
|
|
|
|
|
+ line[0],
|
|
|
|
+ line[1],
|
|
|
|
+ line[0],
|
|
|
|
+ 4 * coordinate.ratio
|
|
|
|
+ );
|
|
const pd2 = help.getPerpendicularPoint(
|
|
const pd2 = help.getPerpendicularPoint(
|
|
- line[0], line[1], line[1], 4 * coordinate.ratio,
|
|
|
|
- )
|
|
|
|
|
|
+ line[0],
|
|
|
|
+ line[1],
|
|
|
|
+ line[1],
|
|
|
|
+ 4 * coordinate.ratio
|
|
|
|
+ );
|
|
const pd3 = help.getPerpendicularPoint(
|
|
const pd3 = help.getPerpendicularPoint(
|
|
- line[0], line[1], line[0], -4 * coordinate.ratio,
|
|
|
|
- )
|
|
|
|
|
|
+ line[0],
|
|
|
|
+ line[1],
|
|
|
|
+ line[0],
|
|
|
|
+ -4 * coordinate.ratio
|
|
|
|
+ );
|
|
const pd4 = help.getPerpendicularPoint(
|
|
const pd4 = help.getPerpendicularPoint(
|
|
- line[0], line[1], line[1], -4 * coordinate.ratio,
|
|
|
|
- )
|
|
|
|
|
|
+ line[0],
|
|
|
|
+ line[1],
|
|
|
|
+ line[1],
|
|
|
|
+ -4 * coordinate.ratio
|
|
|
|
+ );
|
|
|
|
|
|
ctx.moveTo(pd1.x, pd1.y);
|
|
ctx.moveTo(pd1.x, pd1.y);
|
|
ctx.lineTo(pd2.x, pd2.y);
|
|
ctx.lineTo(pd2.x, pd2.y);
|
|
@@ -254,24 +282,24 @@ const help = {
|
|
|
|
|
|
ctx.moveTo(pd3.x, pd3.y);
|
|
ctx.moveTo(pd3.x, pd3.y);
|
|
ctx.lineTo(pd4.x, pd4.y);
|
|
ctx.lineTo(pd4.x, pd4.y);
|
|
- break
|
|
|
|
|
|
+ break;
|
|
case VectorStyle.BrokenLine:
|
|
case VectorStyle.BrokenLine:
|
|
- const ldis = 5 * coordinate.ratio
|
|
|
|
|
|
+ const ldis = 5 * coordinate.ratio;
|
|
if (mathUtil.getDistance(...line) < ldis * 2) {
|
|
if (mathUtil.getDistance(...line) < ldis * 2) {
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
} else {
|
|
} else {
|
|
- const start = mathUtil.translate(line[0], line[1], line[0], ldis)
|
|
|
|
- const end = mathUtil.translate(line[0], line[1], line[1], -ldis)
|
|
|
|
- const lineDis = mathUtil.getDistance(start, end)
|
|
|
|
- const len = Math.ceil(lineDis / (6 * coordinate.ratio))
|
|
|
|
- const split = lineDis / len
|
|
|
|
-
|
|
|
|
- const points = [start]
|
|
|
|
- let temp = start
|
|
|
|
- for (let i = 0; i < len ; i++) {
|
|
|
|
- temp = mathUtil.translate(temp, line[1], temp, split)
|
|
|
|
- points.push(temp)
|
|
|
|
|
|
+ const start = mathUtil.translate(line[0], line[1], line[0], ldis);
|
|
|
|
+ const end = mathUtil.translate(line[0], line[1], line[1], -ldis);
|
|
|
|
+ const lineDis = mathUtil.getDistance(start, end);
|
|
|
|
+ const len = Math.ceil(lineDis / (6 * coordinate.ratio));
|
|
|
|
+ const split = lineDis / len;
|
|
|
|
+
|
|
|
|
+ const points = [start];
|
|
|
|
+ let temp = start;
|
|
|
|
+ for (let i = 0; i < len; i++) {
|
|
|
|
+ temp = mathUtil.translate(temp, line[1], temp, split);
|
|
|
|
+ points.push(temp);
|
|
}
|
|
}
|
|
|
|
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
@@ -281,68 +309,66 @@ const help = {
|
|
points[i],
|
|
points[i],
|
|
points[i + 1],
|
|
points[i + 1],
|
|
mathUtil.lineCenter(points[i], points[i + 1]),
|
|
mathUtil.lineCenter(points[i], points[i + 1]),
|
|
- (split * ((i%2) ? -1 : 1)) / 2
|
|
|
|
- )
|
|
|
|
|
|
+ (split * (i % 2 ? -1 : 1)) / 2
|
|
|
|
+ );
|
|
ctx.lineTo(vTop.x, vTop.y);
|
|
ctx.lineTo(vTop.x, vTop.y);
|
|
}
|
|
}
|
|
ctx.lineTo(end.x, end.y);
|
|
ctx.lineTo(end.x, end.y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
}
|
|
}
|
|
- ctx.lineWidth = lineWidth
|
|
|
|
- break
|
|
|
|
|
|
+ ctx.lineWidth = lineWidth;
|
|
|
|
+ break;
|
|
case VectorStyle.Greenbelt:
|
|
case VectorStyle.Greenbelt:
|
|
- const dis = 4 * coordinate.ratio
|
|
|
|
- const size = 8 * coordinate.ratio
|
|
|
|
- const p1 = help.getPerpendicularPoint(
|
|
|
|
- line[0], line[1], line[0], dis
|
|
|
|
- )
|
|
|
|
- const p2 = help.getPerpendicularPoint(
|
|
|
|
- line[0], line[1], line[1], dis
|
|
|
|
- )
|
|
|
|
- const p3 = help.getPerpendicularPoint(
|
|
|
|
- p1, p2, p2, size
|
|
|
|
- )
|
|
|
|
- const p4 = help.getPerpendicularPoint(
|
|
|
|
- p1, p2, p1, size
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- ctx.beginPath()
|
|
|
|
- ctx.lineWidth = lineWidth
|
|
|
|
|
|
+ const dis = 4 * coordinate.ratio;
|
|
|
|
+ const size = 8 * coordinate.ratio;
|
|
|
|
+ const p1 = help.getPerpendicularPoint(line[0], line[1], line[0], dis);
|
|
|
|
+ const p2 = help.getPerpendicularPoint(line[0], line[1], line[1], dis);
|
|
|
|
+ const p3 = help.getPerpendicularPoint(p1, p2, p2, size);
|
|
|
|
+ const p4 = help.getPerpendicularPoint(p1, p2, p1, size);
|
|
|
|
+
|
|
|
|
+ ctx.beginPath();
|
|
|
|
+ ctx.lineWidth = lineWidth;
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
ctx.moveTo(line[0].x, line[0].y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
ctx.lineTo(line[1].x, line[1].y);
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
- ctx.beginPath()
|
|
|
|
|
|
+ ctx.beginPath();
|
|
ctx.moveTo(p4.x, p4.y);
|
|
ctx.moveTo(p4.x, p4.y);
|
|
ctx.lineTo(p1.x, p1.y);
|
|
ctx.lineTo(p1.x, p1.y);
|
|
ctx.lineTo(p2.x, p2.y);
|
|
ctx.lineTo(p2.x, p2.y);
|
|
ctx.lineTo(p3.x, p3.y);
|
|
ctx.lineTo(p3.x, p3.y);
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
|
|
|
|
|
|
+ const rdis = 6 * coordinate.ratio;
|
|
|
|
+ const lineDis = mathUtil.getDistance(p3, p4);
|
|
|
|
+ const len = Math.ceil(lineDis / rdis);
|
|
|
|
+ const split = lineDis / len;
|
|
|
|
+ const points = [p3];
|
|
|
|
+ const geo = [p4, { ...p4, x: 999 }, p3];
|
|
|
|
+ let angle = (mathUtil.Angle1(...geo) / 180) * Math.PI;
|
|
|
|
+ const isClock = help.isTriangleClockwise(...geo) || angle === 0;
|
|
|
|
|
|
- const rdis = 6 * coordinate.ratio
|
|
|
|
- const lineDis = mathUtil.getDistance(p3, p4)
|
|
|
|
- const len = Math.ceil(lineDis / rdis)
|
|
|
|
- const split = lineDis / len
|
|
|
|
- const points = [p3]
|
|
|
|
- const geo = [p4, {...p4, x: 999}, p3]
|
|
|
|
- let angle = (mathUtil.Angle1(...geo) / 180) * Math.PI
|
|
|
|
- const isClock = help.isTriangleClockwise(...geo) || angle === 0
|
|
|
|
-
|
|
|
|
- angle = isClock ? -angle : angle
|
|
|
|
|
|
+ angle = isClock ? -angle : angle;
|
|
|
|
|
|
- let temp = p3
|
|
|
|
|
|
+ let temp = p3;
|
|
for (let i = 0; i < len; i++) {
|
|
for (let i = 0; i < len; i++) {
|
|
- temp = mathUtil.translate(temp, p4, temp, split)
|
|
|
|
- points.push(temp)
|
|
|
|
|
|
+ temp = mathUtil.translate(temp, p4, temp, split);
|
|
|
|
+ points.push(temp);
|
|
}
|
|
}
|
|
for (let i = 0; i < points.length - 1; i++) {
|
|
for (let i = 0; i < points.length - 1; i++) {
|
|
- const center = mathUtil.lineCenter(points[i], points[i+1])
|
|
|
|
- ctx.beginPath()
|
|
|
|
- ctx.arc(center.x, center.y, split / 2, angle, angle + Math.PI, !isClock)
|
|
|
|
|
|
+ const center = mathUtil.lineCenter(points[i], points[i + 1]);
|
|
|
|
+ ctx.beginPath();
|
|
|
|
+ ctx.arc(
|
|
|
|
+ center.x,
|
|
|
|
+ center.y,
|
|
|
|
+ split / 2,
|
|
|
|
+ angle,
|
|
|
|
+ angle + Math.PI,
|
|
|
|
+ !isClock
|
|
|
|
+ );
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
}
|
|
}
|
|
- ctx.lineWidth = lineWidth
|
|
|
|
- break
|
|
|
|
|
|
+ ctx.lineWidth = lineWidth;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
ctx.restore();
|
|
ctx.restore();
|
|
@@ -433,7 +459,7 @@ export default class Draw {
|
|
const endScreen = coordinate.getScreenXY(midDivide.end);
|
|
const endScreen = coordinate.getScreenXY(midDivide.end);
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
if (label) {
|
|
if (label) {
|
|
- help.setStyle(ctx, Style.Focus.Road)
|
|
|
|
|
|
+ help.setStyle(ctx, Style.Focus.Road);
|
|
}
|
|
}
|
|
ctx.moveTo(startScreen.x, startScreen.y);
|
|
ctx.moveTo(startScreen.x, startScreen.y);
|
|
ctx.lineTo(endScreen.x, endScreen.y);
|
|
ctx.lineTo(endScreen.x, endScreen.y);
|
|
@@ -474,14 +500,13 @@ export default class Draw {
|
|
ctx.save();
|
|
ctx.save();
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
help.setVectorStyle(ctx, null, "Lane");
|
|
help.setVectorStyle(ctx, null, "Lane");
|
|
- ctx.lineWidth *= Settings.lineWidth
|
|
|
|
|
|
+ ctx.lineWidth *= Settings.lineWidth;
|
|
ctx.setLineDash(Style.Lane.dash);
|
|
ctx.setLineDash(Style.Lane.dash);
|
|
ctx.moveTo(start.x, start.y);
|
|
ctx.moveTo(start.x, start.y);
|
|
ctx.lineTo(end.x, end.y);
|
|
ctx.lineTo(end.x, end.y);
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
ctx.restore();
|
|
ctx.restore();
|
|
|
|
|
|
-
|
|
|
|
if (import.meta.env.DEV) {
|
|
if (import.meta.env.DEV) {
|
|
// this.drawPoint(lan.start);
|
|
// this.drawPoint(lan.start);
|
|
// this.drawPoint(lan.end);
|
|
// this.drawPoint(lan.end);
|
|
@@ -495,7 +520,6 @@ export default class Draw {
|
|
: dataService.getRoadPoint(vector.startId);
|
|
: dataService.getRoadPoint(vector.startId);
|
|
const end = isTemp ? vector.end : dataService.getRoadPoint(vector.endId);
|
|
const end = isTemp ? vector.end : dataService.getRoadPoint(vector.endId);
|
|
|
|
|
|
-
|
|
|
|
const drawRoadEdgeChild = (edgeVector) => {
|
|
const drawRoadEdgeChild = (edgeVector) => {
|
|
const flag = mathUtil.isSameDirForVector(
|
|
const flag = mathUtil.isSameDirForVector(
|
|
start,
|
|
start,
|
|
@@ -507,7 +531,12 @@ export default class Draw {
|
|
if (flag) {
|
|
if (flag) {
|
|
const point1 = coordinate.getScreenXY(edgeVector.start);
|
|
const point1 = coordinate.getScreenXY(edgeVector.start);
|
|
const point2 = coordinate.getScreenXY(edgeVector.end);
|
|
const point2 = coordinate.getScreenXY(edgeVector.end);
|
|
- help.drawStyleLine(ctx, [point1, point2], edgeVector.style, edgeVector.weight)
|
|
|
|
|
|
+ help.drawStyleLine(
|
|
|
|
+ ctx,
|
|
|
|
+ [point1, point2],
|
|
|
|
+ edgeVector.style,
|
|
|
|
+ edgeVector.weight
|
|
|
|
+ );
|
|
}
|
|
}
|
|
if (import.meta.env.DEV) {
|
|
if (import.meta.env.DEV) {
|
|
this.drawTextByInfo(
|
|
this.drawTextByInfo(
|
|
@@ -530,46 +559,44 @@ export default class Draw {
|
|
ctx.save();
|
|
ctx.save();
|
|
isTemp && (ctx.globalAlpha = 0.3);
|
|
isTemp && (ctx.globalAlpha = 0.3);
|
|
help.setVectorStyle(ctx, leftEdge);
|
|
help.setVectorStyle(ctx, leftEdge);
|
|
- let [style, fo] = help.getVectorStyle(vector)
|
|
|
|
- fo && help.setStyle(ctx, style)
|
|
|
|
|
|
+ let [style, fo] = help.getVectorStyle(vector);
|
|
|
|
+ fo && help.setStyle(ctx, style);
|
|
drawRoadEdgeChild(leftEdge);
|
|
drawRoadEdgeChild(leftEdge);
|
|
|
|
|
|
help.setVectorStyle(ctx, rightEdge);
|
|
help.setVectorStyle(ctx, rightEdge);
|
|
- fo && help.setStyle(ctx, style)
|
|
|
|
|
|
+ fo && help.setStyle(ctx, style);
|
|
|
|
|
|
drawRoadEdgeChild(rightEdge);
|
|
drawRoadEdgeChild(rightEdge);
|
|
|
|
|
|
ctx.restore();
|
|
ctx.restore();
|
|
|
|
|
|
if (fo) {
|
|
if (fo) {
|
|
- ctx.save()
|
|
|
|
|
|
+ ctx.save();
|
|
const p1 = coordinate.getScreenXY(leftEdge.start);
|
|
const p1 = coordinate.getScreenXY(leftEdge.start);
|
|
const p2 = coordinate.getScreenXY(rightEdge.start);
|
|
const p2 = coordinate.getScreenXY(rightEdge.start);
|
|
const p3 = coordinate.getScreenXY(leftEdge.end);
|
|
const p3 = coordinate.getScreenXY(leftEdge.end);
|
|
const p4 = coordinate.getScreenXY(rightEdge.end);
|
|
const p4 = coordinate.getScreenXY(rightEdge.end);
|
|
- ctx.lineWidth = 1 * coordinate.ratio
|
|
|
|
- ctx.setLineDash([5 * coordinate.ratio, 5 * coordinate.ratio ]);
|
|
|
|
- ctx.strokeStyle = Style.Road.strokeStyle
|
|
|
|
-
|
|
|
|
- ctx.beginPath()
|
|
|
|
- ctx.moveTo(p1.x, p1.y)
|
|
|
|
- ctx.lineTo(p2.x, p2.y)
|
|
|
|
- ctx.stroke()
|
|
|
|
- ctx.beginPath()
|
|
|
|
- ctx.moveTo(p3.x, p3.y)
|
|
|
|
- ctx.lineTo(p4.x, p4.y)
|
|
|
|
- ctx.stroke()
|
|
|
|
-
|
|
|
|
- ctx.fillStyle = 'rgba(23, 121, 237, 0.30)'
|
|
|
|
- ctx.moveTo(p1.x, p1.y)
|
|
|
|
- ctx.lineTo(p2.x, p2.y)
|
|
|
|
- ctx.lineTo(p4.x, p4.y)
|
|
|
|
- ctx.lineTo(p3.x, p3.y)
|
|
|
|
- ctx.fill()
|
|
|
|
- ctx.restore()
|
|
|
|
- }
|
|
|
|
|
|
+ ctx.lineWidth = 1 * coordinate.ratio;
|
|
|
|
+ ctx.setLineDash([5 * coordinate.ratio, 5 * coordinate.ratio]);
|
|
|
|
+ ctx.strokeStyle = Style.Road.strokeStyle;
|
|
|
|
|
|
|
|
+ ctx.beginPath();
|
|
|
|
+ ctx.moveTo(p1.x, p1.y);
|
|
|
|
+ ctx.lineTo(p2.x, p2.y);
|
|
|
|
+ ctx.stroke();
|
|
|
|
+ ctx.beginPath();
|
|
|
|
+ ctx.moveTo(p3.x, p3.y);
|
|
|
|
+ ctx.lineTo(p4.x, p4.y);
|
|
|
|
+ ctx.stroke();
|
|
|
|
|
|
|
|
+ ctx.fillStyle = "rgba(23, 121, 237, 0.30)";
|
|
|
|
+ ctx.moveTo(p1.x, p1.y);
|
|
|
|
+ ctx.lineTo(p2.x, p2.y);
|
|
|
|
+ ctx.lineTo(p4.x, p4.y);
|
|
|
|
+ ctx.lineTo(p3.x, p3.y);
|
|
|
|
+ ctx.fill();
|
|
|
|
+ ctx.restore();
|
|
|
|
+ }
|
|
|
|
|
|
if (import.meta.env.DEV) {
|
|
if (import.meta.env.DEV) {
|
|
// this.drawPoint(leftEdge.start);
|
|
// this.drawPoint(leftEdge.start);
|
|
@@ -600,7 +627,7 @@ export default class Draw {
|
|
const extremePoint = coordinate.getScreenXY(vector.extremePoint);
|
|
const extremePoint = coordinate.getScreenXY(vector.extremePoint);
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
ctx.save();
|
|
ctx.save();
|
|
- help.setVectorStyle(ctx, vector)
|
|
|
|
|
|
+ help.setVectorStyle(ctx, vector);
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
ctx.arc(
|
|
ctx.arc(
|
|
extremePoint.x,
|
|
extremePoint.x,
|
|
@@ -629,13 +656,14 @@ export default class Draw {
|
|
drawCurveRoad(vector) {
|
|
drawCurveRoad(vector) {
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
ctx.save();
|
|
ctx.save();
|
|
- let midCovesArray
|
|
|
|
|
|
+ let midCovesArray;
|
|
const [_, foo] = help.setVectorStyle(ctx, vector);
|
|
const [_, foo] = help.setVectorStyle(ctx, vector);
|
|
if (vector.display && vector.midDivide) {
|
|
if (vector.display && vector.midDivide) {
|
|
midCovesArray = help.transformCoves([
|
|
midCovesArray = help.transformCoves([
|
|
vector.midDivide.leftMidDivideCurves,
|
|
vector.midDivide.leftMidDivideCurves,
|
|
- vector.midDivide.rightMidDivideCurves,
|
|
|
|
|
|
+ // vector.midDivide.rightMidDivideCurves,
|
|
]);
|
|
]);
|
|
|
|
+ ctx.setLineDash([8 * coordinate.ratio, 8 * coordinate.ratio])
|
|
ctx.lineWidth *= Settings.lineWidth
|
|
ctx.lineWidth *= Settings.lineWidth
|
|
for (let coves of midCovesArray) {
|
|
for (let coves of midCovesArray) {
|
|
help.drawCoves(ctx, coves);
|
|
help.drawCoves(ctx, coves);
|
|
@@ -643,75 +671,77 @@ export default class Draw {
|
|
}
|
|
}
|
|
ctx.restore();
|
|
ctx.restore();
|
|
|
|
|
|
- this.drawCurveRoadEdge(dataService.getCurveRoadEdge(vector.rightEdgeId), vector);
|
|
|
|
- this.drawCurveRoadEdge(dataService.getCurveRoadEdge(vector.leftEdgeId), vector);
|
|
|
|
|
|
+ this.drawCurveRoadEdge(
|
|
|
|
+ dataService.getCurveRoadEdge(vector.rightEdgeId),
|
|
|
|
+ vector
|
|
|
|
+ );
|
|
|
|
+ this.drawCurveRoadEdge(
|
|
|
|
+ dataService.getCurveRoadEdge(vector.leftEdgeId),
|
|
|
|
+ vector
|
|
|
|
+ );
|
|
vector.leftLanesCurves &&
|
|
vector.leftLanesCurves &&
|
|
vector.leftLanesCurves.forEach(this.drawCurveLan.bind(this));
|
|
vector.leftLanesCurves.forEach(this.drawCurveLan.bind(this));
|
|
vector.rightLanesCurves &&
|
|
vector.rightLanesCurves &&
|
|
vector.rightLanesCurves.forEach(this.drawCurveLan.bind(this));
|
|
vector.rightLanesCurves.forEach(this.drawCurveLan.bind(this));
|
|
|
|
|
|
-
|
|
|
|
if (foo) {
|
|
if (foo) {
|
|
- const leftEdge = dataService.getCurveRoadEdge(vector.leftEdgeId)
|
|
|
|
- const rightEdge = dataService.getCurveRoadEdge(vector.rightEdgeId)
|
|
|
|
|
|
+ const leftEdge = dataService.getCurveRoadEdge(vector.leftEdgeId);
|
|
|
|
+ const rightEdge = dataService.getCurveRoadEdge(vector.rightEdgeId);
|
|
const p1 = coordinate.getScreenXY(leftEdge.start);
|
|
const p1 = coordinate.getScreenXY(leftEdge.start);
|
|
const p2 = coordinate.getScreenXY(rightEdge.start);
|
|
const p2 = coordinate.getScreenXY(rightEdge.start);
|
|
const p3 = coordinate.getScreenXY(leftEdge.end);
|
|
const p3 = coordinate.getScreenXY(leftEdge.end);
|
|
const p4 = coordinate.getScreenXY(rightEdge.end);
|
|
const p4 = coordinate.getScreenXY(rightEdge.end);
|
|
ctx.save();
|
|
ctx.save();
|
|
- ctx.setLineDash([5 * coordinate.ratio, 5 * coordinate.ratio ]);
|
|
|
|
- ctx.lineWidth = 1 * coordinate.ratio
|
|
|
|
- ctx.strokeStyle = Style.Lane.strokeStyle
|
|
|
|
- ctx.beginPath()
|
|
|
|
- ctx.moveTo(p1.x, p1.y)
|
|
|
|
- ctx.lineTo(p2.x, p2.y)
|
|
|
|
- ctx.stroke()
|
|
|
|
- ctx.beginPath()
|
|
|
|
- ctx.moveTo(p3.x, p3.y)
|
|
|
|
- ctx.lineTo(p4.x, p4.y)
|
|
|
|
- ctx.stroke()
|
|
|
|
|
|
+ ctx.setLineDash([5 * coordinate.ratio, 5 * coordinate.ratio]);
|
|
|
|
+ ctx.lineWidth = 1 * coordinate.ratio;
|
|
|
|
+ ctx.strokeStyle = Style.Lane.strokeStyle;
|
|
|
|
+ ctx.beginPath();
|
|
|
|
+ ctx.moveTo(p1.x, p1.y);
|
|
|
|
+ ctx.lineTo(p2.x, p2.y);
|
|
|
|
+ ctx.stroke();
|
|
|
|
+ ctx.beginPath();
|
|
|
|
+ ctx.moveTo(p3.x, p3.y);
|
|
|
|
+ ctx.lineTo(p4.x, p4.y);
|
|
|
|
+ ctx.stroke();
|
|
|
|
|
|
if (midCovesArray) {
|
|
if (midCovesArray) {
|
|
const edgeCurves = help.transformCoves([
|
|
const edgeCurves = help.transformCoves([
|
|
leftEdge.curves,
|
|
leftEdge.curves,
|
|
- rightEdge.curves
|
|
|
|
|
|
+ rightEdge.curves,
|
|
]);
|
|
]);
|
|
- edgeCurves[1] = edgeCurves[1].reverse().map(curve => ({
|
|
|
|
|
|
+ edgeCurves[1] = edgeCurves[1].reverse().map((curve) => ({
|
|
start: curve.end,
|
|
start: curve.end,
|
|
end: curve.start,
|
|
end: curve.start,
|
|
- controls: curve.controls.reverse()
|
|
|
|
- }))
|
|
|
|
-
|
|
|
|
|
|
+ controls: curve.controls.reverse(),
|
|
|
|
+ }));
|
|
|
|
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
- ctx.setLineDash([])
|
|
|
|
|
|
+ ctx.setLineDash([]);
|
|
ctx.moveTo(edgeCurves[0][0].start.x, edgeCurves[0][0].start.y);
|
|
ctx.moveTo(edgeCurves[0][0].start.x, edgeCurves[0][0].start.y);
|
|
- edgeCurves[0].forEach(cuve => help.drawCove(ctx, cuve))
|
|
|
|
- ctx.lineTo(edgeCurves[1][0].start.x, edgeCurves[1][0].start.y)
|
|
|
|
- edgeCurves[1].forEach(cuve => help.drawCove(ctx, cuve))
|
|
|
|
- ctx.closePath()
|
|
|
|
- ctx.fillStyle = 'rgba(23, 121, 237, 0.30)'
|
|
|
|
- ctx.fill()
|
|
|
|
|
|
+ edgeCurves[0].forEach((cuve) => help.drawCove(ctx, cuve));
|
|
|
|
+ ctx.lineTo(edgeCurves[1][0].start.x, edgeCurves[1][0].start.y);
|
|
|
|
+ edgeCurves[1].forEach((cuve) => help.drawCove(ctx, cuve));
|
|
|
|
+ ctx.closePath();
|
|
|
|
+ ctx.fillStyle = "rgba(23, 121, 237, 0.30)";
|
|
|
|
+ ctx.fill();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
ctx.restore();
|
|
ctx.restore();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// if (import.meta.env.DEV) {
|
|
// if (import.meta.env.DEV) {
|
|
- vector.points.forEach(this.drawPoint.bind(this));
|
|
|
|
|
|
+ vector.points.forEach(this.drawPoint.bind(this));
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
drawCurveRoadEdge(vector, roadVector) {
|
|
drawCurveRoadEdge(vector, roadVector) {
|
|
const [coves] = help.transformCoves([vector.curves]);
|
|
const [coves] = help.transformCoves([vector.curves]);
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
- const [style, select] = help.getVectorStyle(roadVector)
|
|
|
|
|
|
+ const [style, select] = help.getVectorStyle(roadVector);
|
|
ctx.save();
|
|
ctx.save();
|
|
help.setVectorStyle(ctx, vector);
|
|
help.setVectorStyle(ctx, vector);
|
|
- select && help.setStyle(ctx, style)
|
|
|
|
- ctx.lineWidth *= Settings.lineWidth
|
|
|
|
|
|
+ select && help.setStyle(ctx, style);
|
|
|
|
+ ctx.lineWidth *= Settings.lineWidth;
|
|
help.drawCoves(ctx, coves);
|
|
help.drawCoves(ctx, coves);
|
|
ctx.restore();
|
|
ctx.restore();
|
|
|
|
|
|
@@ -726,16 +756,16 @@ export default class Draw {
|
|
ctx.save();
|
|
ctx.save();
|
|
|
|
|
|
help.setVectorStyle(ctx, null, "CurveLan");
|
|
help.setVectorStyle(ctx, null, "CurveLan");
|
|
- ctx.lineWidth *= Settings.lineWidth
|
|
|
|
|
|
+ ctx.lineWidth *= Settings.lineWidth;
|
|
ctx.setLineDash(Style.Lane.dash);
|
|
ctx.setLineDash(Style.Lane.dash);
|
|
help.drawCoves(ctx, coves);
|
|
help.drawCoves(ctx, coves);
|
|
ctx.restore();
|
|
ctx.restore();
|
|
|
|
|
|
// if (import.meta.env.DEV) {
|
|
// if (import.meta.env.DEV) {
|
|
- lines.map((line) => {
|
|
|
|
- this.drawPoint(line.start);
|
|
|
|
- this.drawPoint(line.end);
|
|
|
|
- });
|
|
|
|
|
|
+ lines.map((line) => {
|
|
|
|
+ this.drawPoint(line.start);
|
|
|
|
+ this.drawPoint(line.end);
|
|
|
|
+ });
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
@@ -791,7 +821,7 @@ export default class Draw {
|
|
y: vector.popPosition.y,
|
|
y: vector.popPosition.y,
|
|
};
|
|
};
|
|
const offset = radius / 2;
|
|
const offset = radius / 2;
|
|
- const targetPts =[mathUtil.translate(pt, target, pt, radius), target];
|
|
|
|
|
|
+ const targetPts = [mathUtil.translate(pt, target, pt, radius), target];
|
|
|
|
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
ctx.moveTo(pt.x - offset, pt.y);
|
|
ctx.moveTo(pt.x - offset, pt.y);
|
|
@@ -811,13 +841,15 @@ export default class Draw {
|
|
let img, imgBound;
|
|
let img, imgBound;
|
|
if (vector.photoImage) {
|
|
if (vector.photoImage) {
|
|
img = vector.photoImage;
|
|
img = vector.photoImage;
|
|
- let top = 0, left = 0, size = 0
|
|
|
|
|
|
+ let top = 0,
|
|
|
|
+ left = 0,
|
|
|
|
+ size = 0;
|
|
if (img.width > img.height) {
|
|
if (img.width > img.height) {
|
|
- size = img.height
|
|
|
|
- left = (img.width - size) / 2
|
|
|
|
|
|
+ size = img.height;
|
|
|
|
+ left = (img.width - size) / 2;
|
|
} else {
|
|
} else {
|
|
- size = img.width
|
|
|
|
- top = (img.height - size) / 2
|
|
|
|
|
|
+ size = img.width;
|
|
|
|
+ top = (img.height - size) / 2;
|
|
}
|
|
}
|
|
|
|
|
|
imgBound = [left, top, size, size];
|
|
imgBound = [left, top, size, size];
|
|
@@ -859,7 +891,7 @@ export default class Draw {
|
|
|
|
|
|
drawElliptic(element, radiusX = element.radiusX, radiusY = element.radiusY) {
|
|
drawElliptic(element, radiusX = element.radiusX, radiusY = element.radiusY) {
|
|
function drawEllipse(context, x, y, a, b) {
|
|
function drawEllipse(context, x, y, a, b) {
|
|
- const step = (a > b) ? 1 / a : 1 / b;
|
|
|
|
|
|
+ const step = a > b ? 1 / a : 1 / b;
|
|
context.beginPath();
|
|
context.beginPath();
|
|
context.moveTo(x + a, y);
|
|
context.moveTo(x + a, y);
|
|
for (let i = 0; i < 2 * Math.PI; i += step) {
|
|
for (let i = 0; i < 2 * Math.PI; i += step) {
|
|
@@ -868,47 +900,56 @@ export default class Draw {
|
|
context.closePath();
|
|
context.closePath();
|
|
}
|
|
}
|
|
|
|
|
|
- const pt = coordinate.getScreenXY({ x: element.center.x, y: element.center.y });
|
|
|
|
|
|
+ const pt = coordinate.getScreenXY({
|
|
|
|
+ x: element.center.x,
|
|
|
|
+ y: element.center.y,
|
|
|
|
+ });
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
ctx.save();
|
|
ctx.save();
|
|
const [_, label] = help.setVectorStyle(ctx, element);
|
|
const [_, label] = help.setVectorStyle(ctx, element);
|
|
|
|
|
|
- ctx.strokeStyle = element.color
|
|
|
|
|
|
+ ctx.strokeStyle = element.color;
|
|
drawEllipse(
|
|
drawEllipse(
|
|
- ctx, pt.x, pt.y,
|
|
|
|
|
|
+ ctx,
|
|
|
|
+ pt.x,
|
|
|
|
+ pt.y,
|
|
(radiusX * coordinate.zoom) / coordinate.defaultZoom,
|
|
(radiusX * coordinate.zoom) / coordinate.defaultZoom,
|
|
(radiusY * coordinate.zoom) / coordinate.defaultZoom
|
|
(radiusY * coordinate.zoom) / coordinate.defaultZoom
|
|
- )
|
|
|
|
|
|
+ );
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
ctx.fill();
|
|
ctx.fill();
|
|
ctx.restore();
|
|
ctx.restore();
|
|
}
|
|
}
|
|
|
|
|
|
drawCircle(element) {
|
|
drawCircle(element) {
|
|
- this.context.save()
|
|
|
|
- const geo = [element.center, element.points[1], {...element.center, x: 999}]
|
|
|
|
- let angle = mathUtil.Angle(...geo)
|
|
|
|
- angle = help.isTriangleClockwise(...geo) ? -angle : angle
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- const center = coordinate.getScreenXY(element.center)
|
|
|
|
- this.context.translate(center.x, center.y)
|
|
|
|
- this.context.rotate((angle / 180) * Math.PI)
|
|
|
|
- this.context.translate(-center.x, -center.y)
|
|
|
|
- this.drawElliptic(element, element.radiusX, element.radiusY)
|
|
|
|
- this.context.restore()
|
|
|
|
|
|
+ this.context.save();
|
|
|
|
+ const geo = [
|
|
|
|
+ element.center,
|
|
|
|
+ element.points[1],
|
|
|
|
+ { ...element.center, x: 999 },
|
|
|
|
+ ];
|
|
|
|
+ let angle = mathUtil.Angle(...geo);
|
|
|
|
+ angle = help.isTriangleClockwise(...geo) ? -angle : angle;
|
|
|
|
+
|
|
|
|
+ const center = coordinate.getScreenXY(element.center);
|
|
|
|
+ this.context.translate(center.x, center.y);
|
|
|
|
+ this.context.rotate((angle / 180) * Math.PI);
|
|
|
|
+ this.context.translate(-center.x, -center.y);
|
|
|
|
+ this.drawElliptic(element, element.radiusX, element.radiusY);
|
|
|
|
+ this.context.restore();
|
|
|
|
|
|
const [_, label] = help.getVectorStyle(element);
|
|
const [_, label] = help.getVectorStyle(element);
|
|
label && element.points.forEach((point) => this.drawPoint(point));
|
|
label && element.points.forEach((point) => this.drawPoint(point));
|
|
}
|
|
}
|
|
|
|
|
|
drawPoint(vector, screenSave) {
|
|
drawPoint(vector, screenSave) {
|
|
- const screenNotDrawTypes = [
|
|
|
|
- VectorCategory.Point.NormalPoint,
|
|
|
|
- ]
|
|
|
|
|
|
+ const screenNotDrawTypes = [VectorCategory.Point.NormalPoint];
|
|
if (!screenSave) {
|
|
if (!screenSave) {
|
|
- if ((Settings.screenMode && (!vector.category || screenNotDrawTypes.includes(vector.category))) ||
|
|
|
|
- (vector.category === VectorCategory.Point.TestBasePoint)) {
|
|
|
|
|
|
+ if (
|
|
|
|
+ (Settings.screenMode &&
|
|
|
|
+ (!vector.category || screenNotDrawTypes.includes(vector.category))) ||
|
|
|
|
+ vector.category === VectorCategory.Point.TestBasePoint
|
|
|
|
+ ) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -930,15 +971,15 @@ export default class Draw {
|
|
const [stylea, attr] = help.getVectorStyle(line, line.category);
|
|
const [stylea, attr] = help.getVectorStyle(line, line.category);
|
|
style = {
|
|
style = {
|
|
...style,
|
|
...style,
|
|
- ...stylea
|
|
|
|
- }
|
|
|
|
|
|
+ ...stylea,
|
|
|
|
+ };
|
|
}
|
|
}
|
|
|
|
|
|
if (vector.color) {
|
|
if (vector.color) {
|
|
ctx.strokeStyle = vector.color;
|
|
ctx.strokeStyle = vector.color;
|
|
style = {
|
|
style = {
|
|
...style,
|
|
...style,
|
|
- strokeStyle: vector.color
|
|
|
|
|
|
+ strokeStyle: vector.color,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
const draw = (style) => {
|
|
const draw = (style) => {
|
|
@@ -951,7 +992,7 @@ export default class Draw {
|
|
ctx.fill();
|
|
ctx.fill();
|
|
ctx.restore();
|
|
ctx.restore();
|
|
};
|
|
};
|
|
- if (Settings.selectBasePointId === vector.vectorId ) {
|
|
|
|
|
|
+ if (Settings.selectBasePointId === vector.vectorId) {
|
|
style = {
|
|
style = {
|
|
...style,
|
|
...style,
|
|
strokeStyle: "rgba(255,255,255,1)",
|
|
strokeStyle: "rgba(255,255,255,1)",
|
|
@@ -962,22 +1003,23 @@ export default class Draw {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //console.log(vector, style, Settings.selectBasePointId)
|
|
draw(style);
|
|
draw(style);
|
|
if (style.out) {
|
|
if (style.out) {
|
|
draw(style.out);
|
|
draw(style.out);
|
|
}
|
|
}
|
|
|
|
|
|
if (vector.category === "BasePoint") {
|
|
if (vector.category === "BasePoint") {
|
|
- ctx.font = `${12 * coordinate.ratio}px Microsoft YaHei`
|
|
|
|
- const bound = help.getTextCenter(ctx, "基准点")
|
|
|
|
|
|
+ ctx.font = `${12 * coordinate.ratio}px Microsoft YaHei`;
|
|
|
|
+ const bound = help.getTextCenter(ctx, "基准点");
|
|
|
|
|
|
- const screen = coordinate.getScreenXY(vector)
|
|
|
|
|
|
+ const screen = coordinate.getScreenXY(vector);
|
|
const textPt = coordinate.getXYFromScreenNotRatio({
|
|
const textPt = coordinate.getXYFromScreenNotRatio({
|
|
y: screen.y + bound.height + style.radius,
|
|
y: screen.y + bound.height + style.radius,
|
|
- x: screen.x - (bound.width / 2)
|
|
|
|
- })
|
|
|
|
|
|
+ x: screen.x - bound.width / 2,
|
|
|
|
+ });
|
|
|
|
|
|
- ctx.fillStyle = style.fillStyle
|
|
|
|
|
|
+ ctx.fillStyle = style.fillStyle;
|
|
this.drawTextByInfo(textPt, "基准点", 0, false);
|
|
this.drawTextByInfo(textPt, "基准点", 0, false);
|
|
} else {
|
|
} else {
|
|
if (import.meta.env.DEV) {
|
|
if (import.meta.env.DEV) {
|
|
@@ -1018,16 +1060,16 @@ export default class Draw {
|
|
this.context.font = `${
|
|
this.context.font = `${
|
|
vector.fontSize * coordinate.ratio
|
|
vector.fontSize * coordinate.ratio
|
|
}px Microsoft YaHei`;
|
|
}px Microsoft YaHei`;
|
|
- const bound = help.getTextCenter(this.context, vector.value)
|
|
|
|
|
|
+ const bound = help.getTextCenter(this.context, vector.value);
|
|
|
|
|
|
// console.log(vector)
|
|
// console.log(vector)
|
|
- const screen = coordinate.getScreenXY(vector.center)
|
|
|
|
|
|
+ const screen = coordinate.getScreenXY(vector.center);
|
|
this.drawTextByInfo(
|
|
this.drawTextByInfo(
|
|
// vector.center,
|
|
// vector.center,
|
|
coordinate.getXYFromScreenNotRatio({
|
|
coordinate.getXYFromScreenNotRatio({
|
|
// y: screen.y + (bound.height + Style.Point.radius),
|
|
// y: screen.y + (bound.height + Style.Point.radius),
|
|
- y: screen.y + (bound.height + Style.Point.radius ),
|
|
|
|
- x: screen.x - (bound.width / 2)
|
|
|
|
|
|
+ y: screen.y + (bound.height + Style.Point.radius),
|
|
|
|
+ x: screen.x - bound.width / 2,
|
|
}),
|
|
}),
|
|
vector.value,
|
|
vector.value,
|
|
-(vector.angle || 0),
|
|
-(vector.angle || 0),
|
|
@@ -1036,7 +1078,8 @@ export default class Draw {
|
|
|
|
|
|
this.context.restore();
|
|
this.context.restore();
|
|
|
|
|
|
- vector.displayPoint && this.drawPoint({...vector.center, color: vector.color}, true)
|
|
|
|
|
|
+ vector.displayPoint &&
|
|
|
|
+ this.drawPoint({ ...vector.center, color: vector.color }, true);
|
|
}
|
|
}
|
|
|
|
|
|
drawSVG(vector) {
|
|
drawSVG(vector) {
|
|
@@ -1054,7 +1097,7 @@ export default class Draw {
|
|
this.context.scale(width / svgWidth, height / svgHidth);
|
|
this.context.scale(width / svgWidth, height / svgHidth);
|
|
const [style, label] = help.setVectorStyle(this.context, vector);
|
|
const [style, label] = help.setVectorStyle(this.context, vector);
|
|
this.context.lineWidth = style.lineWidth / (width / svgWidth);
|
|
this.context.lineWidth = style.lineWidth / (width / svgWidth);
|
|
- SVGIcons[vector.type].draw(this.context);
|
|
|
|
|
|
+ SVGIcons[vector.type].draw(this.context, style.fillStyle, style.strokeStyle);
|
|
this.context.restore();
|
|
this.context.restore();
|
|
|
|
|
|
if (label) {
|
|
if (label) {
|
|
@@ -1064,13 +1107,15 @@ export default class Draw {
|
|
this.context.lineTo(points[1].x, points[1].y);
|
|
this.context.lineTo(points[1].x, points[1].y);
|
|
this.context.lineTo(points[2].x, points[2].y);
|
|
this.context.lineTo(points[2].x, points[2].y);
|
|
this.context.lineTo(points[3].x, points[3].y);
|
|
this.context.lineTo(points[3].x, points[3].y);
|
|
- this.context.strokeStyle = style.strokeStyle
|
|
|
|
- this.context.lineWidth = 2 * coordinate.ratio
|
|
|
|
|
|
+ this.context.strokeStyle = style.strokeStyle;
|
|
|
|
+ this.context.lineWidth = 2 * coordinate.ratio;
|
|
this.context.setLineDash([6 * coordinate.ratio, 2 * coordinate.ratio]);
|
|
this.context.setLineDash([6 * coordinate.ratio, 2 * coordinate.ratio]);
|
|
this.context.closePath();
|
|
this.context.closePath();
|
|
this.context.stroke();
|
|
this.context.stroke();
|
|
this.context.restore();
|
|
this.context.restore();
|
|
- vector.points.forEach(point => this.drawPoint({...point, color: style.strokeStyle, radius: 5 }))
|
|
|
|
|
|
+ vector.points.forEach((point) =>
|
|
|
|
+ this.drawPoint({ ...point, color: style.strokeStyle, radius: 5 })
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1106,7 +1151,7 @@ export default class Draw {
|
|
30 * coordinate.ratio
|
|
30 * coordinate.ratio
|
|
);
|
|
);
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
- ctx.save()
|
|
|
|
|
|
+ ctx.save();
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
const [style] = help.setVectorStyle(
|
|
const [style] = help.setVectorStyle(
|
|
this.context,
|
|
this.context,
|
|
@@ -1135,7 +1180,7 @@ export default class Draw {
|
|
fillColor: style.strokeStyle,
|
|
fillColor: style.strokeStyle,
|
|
}
|
|
}
|
|
);
|
|
);
|
|
- ctx.restore()
|
|
|
|
|
|
+ ctx.restore();
|
|
}
|
|
}
|
|
|
|
|
|
drawCurveLine(vector) {
|
|
drawCurveLine(vector) {
|
|
@@ -1143,7 +1188,9 @@ export default class Draw {
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
ctx.save();
|
|
ctx.save();
|
|
help.setVectorStyle(ctx, vector);
|
|
help.setVectorStyle(ctx, vector);
|
|
- help.drawCoves(ctx, help.transformCoves([vector.points]));
|
|
|
|
|
|
+ help.transformCoves([vector.curves]).forEach((coves) => {
|
|
|
|
+ help.drawCoves(ctx, coves);
|
|
|
|
+ });
|
|
ctx.restore();
|
|
ctx.restore();
|
|
|
|
|
|
if (import.meta.env.DEV) {
|
|
if (import.meta.env.DEV) {
|
|
@@ -1167,8 +1214,7 @@ export default class Draw {
|
|
this.context.setLineDash(style.dash);
|
|
this.context.setLineDash(style.dash);
|
|
}
|
|
}
|
|
|
|
|
|
- help.drawStyleLine(this.context, [start, end], vector.style, vector.weight)
|
|
|
|
-
|
|
|
|
|
|
+ help.drawStyleLine(this.context, [start, end], vector.style, vector.weight);
|
|
|
|
|
|
switch (vector.category) {
|
|
switch (vector.category) {
|
|
case VectorCategory.Line.SingleArrowLine:
|
|
case VectorCategory.Line.SingleArrowLine:
|