From 7ea719c178e47d7fae0e5bb4ddb08474f293e8ab Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 30 Oct 2025 11:09:55 +0100 Subject: [PATCH] Enhance CourtDrawing components with additional target selection and arrow drawing features Added new target selection buttons for main and additional strokes in CourtDrawingTool.vue, allowing users to explicitly choose target positions. Updated CourtDrawingRender.vue to support drawing up to three additional arrows, alternating between left and right sides, with distinct colors for each stroke. Improved the logic for determining the next stroke side and updated related methods for better clarity and functionality. --- .../src/components/CourtDrawingRender.vue | 52 +++-- frontend/src/components/CourtDrawingTool.vue | 180 ++++++++++++++++-- 2 files changed, 197 insertions(+), 35 deletions(-) diff --git a/frontend/src/components/CourtDrawingRender.vue b/frontend/src/components/CourtDrawingRender.vue index c76425e..c8a6b67 100644 --- a/frontend/src/components/CourtDrawingRender.vue +++ b/frontend/src/components/CourtDrawingRender.vue @@ -65,6 +65,8 @@ export default { arrows: { primaryColor: '#d32f2f', // rechts -> target (rot) secondaryColor: '#1565c0', // zurück (blau) + tertiaryColor: '#2e7d32', // dritter Schlag (grün) + quaternaryColor: '#6a1b9a', // vierter Schlag (violett) width: 6, headLength: 24, vhOffsetX: 5, @@ -336,25 +338,39 @@ export default { const startCenter = this.getStartCircleCenter(); this.drawLabelBelow(ctx, sourceLabel, startCenter); } - - // Second arrow (optional): from right source to left target - const leftTarget = this.drawingData.nextStrokeTargetPosition ? Number(this.drawingData.nextStrokeTargetPosition) : null; - if (tp && leftTarget) { - // source near previous right target + + // Additional arrows (up to 3), alternating left/right, starting from right target + const extras = Array.isArray(this.drawingData.additionalStrokes) ? this.drawingData.additionalStrokes : []; + if (tp && extras.length) { + const colors = [ + this.config.arrows.secondaryColor, + this.config.arrows.tertiaryColor, + this.config.arrows.quaternaryColor + ]; + const max = Math.min(3, extras.length); const sourceRightCenter = this.computeRightTargetPosition(tp); - // left target mapping: mirror scheme to left half - const toLeftCenter = this.computeLeftTargetPosition(leftTarget); - // Zielmarkierung links - this.drawHitMarker(ctx, toLeftCenter); - const side = this.drawingData.nextStrokeSide || ''; - const type = this.drawingData.nextStrokeType || ''; - // Text gehört ans Ziel (ohne "extra target") - const targetLabel = `${side} ${type}`.trim(); - const sourceRight = { x: sourceRightCenter.x - this.config.targetCircles.radius, y: sourceRightCenter.y }; - const toLeft = { x: toLeftCenter.x + this.config.leftTargetCircles.radius, y: toLeftCenter.y }; - this.drawArrow(ctx, sourceRight, toLeft, this.config.arrows.secondaryColor); - // Unter dem rechten Ziel (target der ersten Linie) beschriften - this.drawLabelBelow(ctx, targetLabel, sourceRightCenter); + let prevPoint = { x: sourceRightCenter.x - this.config.targetCircles.radius, y: sourceRightCenter.y }; + for (let i = 0; i < max; i++) { + const stroke = extras[i]; + const side = i % 2 === 0 ? 'left' : 'right'; + if (side === 'left') { + const leftNum = Number(stroke.targetPosition); + const toLeftCenter = this.computeLeftTargetPosition(leftNum); + // Zielmarkierung links + this.drawHitMarker(ctx, toLeftCenter); + const toLeft = { x: toLeftCenter.x + this.config.leftTargetCircles.radius, y: toLeftCenter.y }; + this.drawArrow(ctx, prevPoint, toLeft, colors[i]); + prevPoint = toLeft; // beginnt an der Pfeilspitze des vorherigen + } else { + const rightNum = Number(stroke.targetPosition); + const toRightCenter = this.computeRightTargetPosition(rightNum); + // Zielmarkierung rechts + this.drawHitMarker(ctx, toRightCenter); + const toRight = { x: toRightCenter.x - this.config.targetCircles.radius, y: toRightCenter.y }; + this.drawArrow(ctx, prevPoint, toRight, colors[i]); + prevPoint = toRight; + } + } } }, getStartCircleCenter() { diff --git a/frontend/src/components/CourtDrawingTool.vue b/frontend/src/components/CourtDrawingTool.vue index 76273d4..62ad2d1 100644 --- a/frontend/src/components/CourtDrawingTool.vue +++ b/frontend/src/components/CourtDrawingTool.vue @@ -89,6 +89,22 @@ + +
+ Zielposition: +
+ +
+
+
@@ -113,6 +129,22 @@
+ +
+ Zielposition: +
+ +
+
+