Ich habe eine Gruppe erstellt und skaliert.Ich möchte nur die Form der skalierten Gruppe nicht andere Attribute kopieren.Speziell möchte ich von transformierten Matrix loswerden.Ich brauche eine neue Gruppe unabhängig von der skalierte. Ich weiß nicht, ob es möglich ist, das zu tun? Hier ist der Code:Svg Clone nur Form einer skalierten Gruppe
Gruppe für das Auto:
<svg id="game" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" onload="loadFunction()" >
<!-- Car -->
<g id="exCar" x="50" y="500" transform="" >
<path id="front" d="M 40 500 Q 110 450 110 500 L 40 500" fill="pink" stroke="black" />
<path id="window" d="M 40 500 L 50 530 L 100 530 L 110 500 L 40 500 "stroke="black" />
<path id="sides" d="M 40 500 L 40 580 L 50 560 Q 55 550 50 530 L 40 500 M 110 500 L 110 580 L 100 560 Q 95 550 100 530 L 110 500" fill="pink" stroke="black" />
<path id ="back" d="M 40 580 L 100 560 L 40 580" fill="pink" stroke="blue" />
<path id="wheels" d="M 40 475 L 30 475 L 30 500 L 40 500 z M 110 475 L 120 475 L 120 500 L 110 500 z M 40 545 L 30 545 L 30 570 L 40 570 z" fill="yellow" stroke="black" />
<image id="carpicture2" x="50" y="455" xlink:href="img.jpg"></image>
<text id="carName" x="50" y="575"></text>
</g>
</svg>
Taste, um die Funktion aufzurufen:
<rect x="120" y="600" width="80" height="30" stroke:#FF0066" onclick="cloning()"/>
Funktion zu kopieren:
function cloning() {
var newCar = document.getElementById("exCar").cloneNode(true);
newCar.setAttribute("x", 400);
newCar.setAttribute("y", 600);
document.getElementById("game").appendChild(newCar);
alert("!!!!");
};
Skalierung:
document.getElementById("exCar").setAttribute(
"transform",
"matrix(" + result/100 + ",0,0," + result/100 + ","
+ (x - (result/100 * x)) + "," + (y - (result/100 * y))
+ ")");
@mihai bitte nicht geschlafen werden:) – Ecrin
hi, kannst du zeigen, wie du die Skalierung auch machst? – mihai
habe ich zur Skalierung bearbeitet – Ecrin