Fix Gitea Issue #1: Text-Generator Verbesserungen
- Rahmenform Standard auf 'Rechteck' gesetzt (statt 'Keiner') - Pfeile werden nun korrekt im SVG-Bereich dargestellt (viewBox + Padding) - Numerische Eingabefelder neben allen Slidern hinzugefügt - Text-Positionierung im Rahmen ermöglicht (horizontal + vertikal) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,25 +183,49 @@ var SvgGenerator = {
|
||||
var color = options.color;
|
||||
var lines = options.lines;
|
||||
var lineHeight = options.lineHeight;
|
||||
var alignX = options.alignX || 'center';
|
||||
var alignY = options.alignY || 'center';
|
||||
var frameWidth = options.frameWidth || 0;
|
||||
var frameHeight = options.frameHeight || 0;
|
||||
var group = draw.group();
|
||||
|
||||
var totalHeight = lines.length * lineHeight;
|
||||
var startY = y - (totalHeight / 2) + (fontSize * 0.8);
|
||||
var startY;
|
||||
|
||||
// Vertikale Ausrichtung
|
||||
switch(alignY) {
|
||||
case 'top':
|
||||
startY = y - frameHeight / 2 + fontSize * 0.8 + 5;
|
||||
break;
|
||||
case 'bottom':
|
||||
startY = y + frameHeight / 2 - totalHeight + fontSize * 0.8 - 5;
|
||||
break;
|
||||
default: // center
|
||||
startY = y - (totalHeight / 2) + (fontSize * 0.8);
|
||||
}
|
||||
|
||||
// Text-Anchor fuer horizontale Ausrichtung
|
||||
var anchor = alignX === 'left' ? 'start' : (alignX === 'right' ? 'end' : 'middle');
|
||||
var textX = x;
|
||||
if (alignX === 'left') {
|
||||
textX = x - frameWidth / 2 + 5;
|
||||
} else if (alignX === 'right') {
|
||||
textX = x + frameWidth / 2 - 5;
|
||||
}
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var lineY = startY + (i * lineHeight);
|
||||
var lineText = lines[i] || ' ';
|
||||
// Verwende plain SVG text element fuer bessere Kontrolle
|
||||
var textEl = draw.plain(lineText)
|
||||
.font({
|
||||
family: 'Arial, sans-serif',
|
||||
size: fontSize,
|
||||
anchor: 'middle'
|
||||
anchor: anchor
|
||||
})
|
||||
.fill(color)
|
||||
.attr('x', x)
|
||||
.attr('x', textX)
|
||||
.attr('y', lineY)
|
||||
.attr('text-anchor', 'middle');
|
||||
.attr('text-anchor', anchor);
|
||||
group.add(textEl);
|
||||
}
|
||||
return group;
|
||||
@@ -224,13 +248,13 @@ var SvgGenerator = {
|
||||
if (s.arrow !== 'none') {
|
||||
var angleRad = Math.abs(s.arrowAngle) * Math.PI / 180;
|
||||
var bendFactor = s.arrowBend / 100;
|
||||
var effectiveLength = s.arrowLength * (1 - bendFactor);
|
||||
var angledPart = s.arrowLength * (1 - bendFactor);
|
||||
|
||||
// Hauptrichtung: volle Laenge + Spitze + Puffer
|
||||
arrowSpace = s.arrowLength + s.arrowTipLength + 20;
|
||||
// Hauptrichtung: volle Laenge + Spitze + grosszuegiger Puffer
|
||||
arrowSpace = s.arrowLength + s.arrowTipLength + s.arrowSize + 25;
|
||||
|
||||
// Seitliche Abweichung durch Winkel
|
||||
arrowSideSpace = Math.abs(Math.sin(angleRad) * effectiveLength) + s.arrowSize + 10;
|
||||
// Seitliche Abweichung durch Winkel (beruecksichtige Pfeilspitze)
|
||||
arrowSideSpace = Math.abs(Math.sin(angleRad) * angledPart) + s.arrowSize + s.arrowTipLength + 15;
|
||||
}
|
||||
|
||||
var svgWidth = minWidth;
|
||||
@@ -262,7 +286,14 @@ var SvgGenerator = {
|
||||
break;
|
||||
}
|
||||
|
||||
var draw = SVG().size(svgWidth, svgHeight);
|
||||
// Puffer um alle Elemente
|
||||
var padding = 5;
|
||||
svgWidth += padding * 2;
|
||||
svgHeight += padding * 2;
|
||||
offsetX += padding;
|
||||
offsetY += padding;
|
||||
|
||||
var draw = SVG().size(svgWidth, svgHeight).viewbox(0, 0, svgWidth, svgHeight);
|
||||
|
||||
var frameX = offsetX;
|
||||
var frameY = offsetY;
|
||||
@@ -295,7 +326,11 @@ var SvgGenerator = {
|
||||
|
||||
this.createText(draw, s.text, textCx, textCy, {
|
||||
fontSize: s.fontSize, color: s.textColor,
|
||||
lines: textMetrics.lines, lineHeight: textMetrics.lineHeight
|
||||
lines: textMetrics.lines, lineHeight: textMetrics.lineHeight,
|
||||
alignX: s.textAlignX || 'center',
|
||||
alignY: s.textAlignY || 'center',
|
||||
frameWidth: minWidth,
|
||||
frameHeight: minHeight
|
||||
});
|
||||
|
||||
return draw.svg();
|
||||
@@ -353,11 +388,11 @@ var SvgGenerator = {
|
||||
break;
|
||||
}
|
||||
|
||||
// Stelle sicher, dass alle Werte positiv sind
|
||||
width = Math.max(width, 80);
|
||||
height = Math.max(height, 60);
|
||||
// Stelle sicher, dass alle Werte positiv sind und genuegend Platz haben
|
||||
width = Math.max(width, 100);
|
||||
height = Math.max(height, 80);
|
||||
|
||||
var draw = SVG().size(width, height);
|
||||
var draw = SVG().size(width, height).viewbox(0, 0, width, height);
|
||||
|
||||
// Simuliere einen Rahmen-Punkt als Startpunkt
|
||||
var frameRect = {
|
||||
|
||||
Reference in New Issue
Block a user