0
我想重現這個小例子https://developer.mozilla.org/en-US/docs/SVG/Element/animateMotion使用我自己製作的php中的一個類。 這是我的PHP類PHP-Class SVG + jQuery-AJAX
class SVG{//https://developer.mozilla.org/en-US/docs/SVG
//http://www.w3.org/TR/SVG/Overview.html
static function SVG_Frame(array $SVGatt,$conteudoSVG) {//http://www.w3.org/TR/SVG/struct.html#NewDocument
$attrSVG=null;
foreach ($SVGatt as $key => $value) {
if(is_string($key)){
$attrSVG .= " ".$key."=\"".$value."\"";
}
}
return"<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ".$attrSVG.">".$conteudoSVG."</svg>";
}
static function SVG_Circle(array $circleAtt){//http://www.w3.org/TR/SVG/shapes.html#CircleElement
$attrCircle=null;
$conteudoCircle=null;
foreach ($circleAtt as $key => $value) {
if(is_string($key)){
$attrCircle .= " ".$key."=\"".$value."\"";
}
else{
if(is_array($value)){
foreach ($value as $key2 => $value2) {
$conteudoCircle.=$value2;
}
}
else{
$conteudoCircle=$value;
}
}
}
if($conteudoCircle==""){
return "<circle".$attrCircle."/>";
}else{
return "<circle".$attrCircle."/>".$conteudoCircle."</circle>";
}
}
static function SVG_AnimateMotion(array $animateMotAtt) {//http://www.w3.org/TR/SVG/animate.html#AnimateMotionElement //https://developer.mozilla.org/en-US/docs/SVG/Element/animateMotion
$attrAninMot=null;
$conteudoAninMot=null;
foreach ($animateMotAtt as $key => $value) {
if(is_string($key)){
$attrAninMot .= " ".$key."=\"".$value."\"";
}
else{
if(is_array($value)){
foreach ($value as $key2 => $value2) {
$conteudoAninMot.=$value2;
}
}
else{
$conteudoAninMot=$value;
}
}
}
return"<animateMotion ".$attrAninMot."/>".$conteudoAninMot."</animateMotion>";
}
static function SVG_MPath(array $mpathtAtt) {//http://www.w3.org/TR/SVG/animate.html#InterfaceSVGMPathElement
//https://developer.mozilla.org/en-US/docs/SVG/Element/mpath
$attrMPath=null;
foreach ($mpathtAtt as $key => $value) {
$attrMPath .= " ".$key."=\"".$value."\"";
}
return"<mpath ".$attrMPath."/>";
}
static function SVG_Path(array $pathtAtt) {//https://developer.mozilla.org/en-US/docs/SVG/Tutorial/Paths
//http://www.w3.org/TR/SVG/paths.html
$attrPath=null;
foreach ($pathtAtt as $key => $value) {
$attrPath .= " ".$key."=\"".$value."\"";
}
return"<path ".$attrPath."/>";
}
}
這是怎樣一個打電話給我的類
$data="M 10,110
A 120,120 -45 0,1 110 10
A 120,120 -45 0,1 10,110";
$path= SVG::SVG_Path(array(id=>path1,stroke=>"gray",fill=>"none",d=>$data));
$circulo1=SVG::SVG_Circle(array(cx=>10,cy=>110,r=>3,fill=>lightgrey));
$circulo2=SVG::SVG_Circle(array(cx=>110,cy=>10,r=>3,fill=>lightgrey));
$mpath= SVG::SVG_MPath(array("xlink:href"=>"#path1"));
$animate= SVG::SVG_AnimateMotion(array(dur=>"6s",repeatCount=>indefinite,$mpath));
$circuloRed = SVG::SVG_Circle(array(cx=>"",cy=>"",r=>10,fill=>red,$animate));
$svgFrame = SVG::SVG_Frame(array(width=>500,height=>500), $circulo1.$circulo2.$path.$circuloRed);
當我上了XDebug如預期的$ svgFrame看到。但是當在瀏覽器上看到我有那個http://jsfiddle.net/igoralves1/qd5p9/。我不知道爲什麼它不起作用。而當我使用AJAX來到外面和外面。任何想法都會令人滿意。
嗨,朋友,謝謝你的回覆。我發現了這個問題。我在我的課上犯了一個錯誤。 「 」。$ conteudoCircle。「」;我應該改變「/>」爲「>」。對於。$ attrAninMot。「/>」。$ conteudoAninMot。「 animateMotion>」;將「>」更改爲「>」,現在可以正常工作了 –
ABA
2013-02-14 15:39:22
如果解決該問題,其他人讀這個線程將知道;) – vectorialpx 2013-02-15 07:43:03