Ben saf JavaScript bir svg elemanı inşa ediyorum, ama bunun resim eklemek başaramasanız:Javascript'te svg öğesine nasıl resim eklenir?
var svgns = "http://www.w3.org/2000/svg";
var svgElement = document.createElementNS(svgns, "svg");
svgElement.setAttributeNS(null, "width", 100);
svgElement.setAttributeNS(null, "height", 100);
var shape = document.createElementNS(svgns, "circle");
shape.setAttributeNS(null, "cx", 25);
shape.setAttributeNS(null, "cy", 25);
shape.setAttributeNS(null, "r", 20);
shape.setAttributeNS(null, "fill", "green");
var pngImage = document.createElementNS(svgns, "image");
pgnImage.setAttributeNS(null, "x", 0);
pgnImage.setAttributeNS(null, "y", 0);
pgnImage.setAttributeNS(null, "width", 100);
pgnImage.setAttributeNS(null, "height", 100);
pngImage.setAttributeNS(null, "http://www.freedos.org/images/logos/fdfish-glossy-plain.svg")
svgElement.appendChild(shape);
svgElement.appendChild(pgnImage);
document.body.appendChild(svgElement);
Ne yapmaya çalışıyorsunuz? SVG, Ölçeklendirilebilir Vektör Grafikleridir ... görüntülerdir, ancak ayarlanmış piksel yerine koordinatları kullanırlar ... Kendi puanlarınızı çizmeye mi çalışıyorsunuz? İyi şanslar! –
svg'nin içinde bir görüntü öğesi oluşturun. https://stackoverflow.com/questions/6249664/does-svg-support-embedding-of-bitmap-images#6250418 –
JSFiddle'u png görüntüsü yerine svg kullanacak şekilde düzenleyin. – loloof64