PHP绘制3D图形之自定义图形及矢量图_PHP

WBOY
Release: 2016-06-01 12:21:12
Original
1594 people have browsed it

上一篇进行了一些简单3D图形实例,本篇介绍自定义及矢量图实例。首先绘制一个三尖角星体,分别由“前面”,“后面”和三个“侧面”组成。

自定义多边形

代码:

以下为引用的内容:

<span style="COLOR: blue"><?php
require_once</span><span style="COLOR: purple">(</span><span style="COLOR: olive">'Image/3D.php'</span><span style="COLOR: purple">)</span>;
<span style="COLOR: blue">$image </span><span style="COLOR: purple">= </span><span style="COLOR: blue">new </span>Image_3D<span style="COLOR: purple">()</span>;
<span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>setColor<span style="COLOR: purple">(</span><span style="COLOR: blue">new </span>Image_3D_Color<span style="COLOR: purple">(</span><span style="COLOR: red">255</span><span style="COLOR: purple">, </span><span style="COLOR: red">255</span><span style="COLOR: purple">, </span><span style="COLOR: red">255</span><span style="COLOR: purple">))</span>;
<span style="COLOR: green">//创建光源
</span><span style="COLOR: blue">$light1 </span><span style="COLOR: purple">= </span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createLight<span style="COLOR: purple">(</span><span style="COLOR: olive">'light'</span><span style="COLOR: purple">,</span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">50</span><span style="COLOR: purple">, -</span><span style="COLOR: red">50</span><span style="COLOR: purple">, -</span><span style="COLOR: red">50</span><span style="COLOR: purple">))</span>;
<span style="COLOR: blue">$light1</span><span style="COLOR: purple">-></span>setColor<span style="COLOR: purple">(</span><span style="COLOR: blue">new </span>Image_3D_Color<span style="COLOR: purple">(</span><span style="COLOR: red">100</span><span style="COLOR: purple">, </span><span style="COLOR: red">250</span><span style="COLOR: purple">, </span><span style="COLOR: red">100</span><span style="COLOR: purple">))</span>;

<span style="COLOR: blue">$light2 </span><span style="COLOR: purple">= </span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createLight<span style="COLOR: purple">(</span><span style="COLOR: olive">'light'</span><span style="COLOR: purple">,</span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">50</span><span style="COLOR: purple">, -</span><span style="COLOR: red">50</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">))</span>;
<span style="COLOR: blue">$light2</span><span style="COLOR: purple">-></span>setColor<span style="COLOR: purple">(</span><span style="COLOR: blue">new </span>Image_3D_Color<span style="COLOR: purple">(</span><span style="COLOR: red">100</span><span style="COLOR: purple">, </span><span style="COLOR: red">100</span><span style="COLOR: purple">, </span><span style="COLOR: red">250</span><span style="COLOR: purple">))</span>;

<span style="COLOR: blue">$light3 </span><span style="COLOR: purple">= </span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createLight<span style="COLOR: purple">(</span><span style="COLOR: olive">'light'</span><span style="COLOR: purple">,</span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">50</span><span style="COLOR: purple">, </span><span style="COLOR: red">50</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">))</span>;
<span style="COLOR: blue">$light3</span><span style="COLOR: purple">-></span>setColor<span style="COLOR: purple">(</span><span style="COLOR: blue">new </span>Image_3D_Color<span style="COLOR: purple">(</span><span style="COLOR: red">50</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">, </span><span style="COLOR: red">100</span><span style="COLOR: purple">))</span>;

<span style="COLOR: green">//创建多边形数组
</span><span style="COLOR: blue">$polygons </span><span style="COLOR: purple">= </span><span style="COLOR: blue">array</span><span style="COLOR: purple">()</span>;

<span style="COLOR: green">//前面点坐标
</span><span style="COLOR: blue">$polygons</span><span style="COLOR: purple">[] = </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, -</span><span style="COLOR: red">120</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, </span><span style="COLOR: red">18</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">),  </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">)
              )</span>;

<span style="COLOR: green">//后面点坐标
</span><span style="COLOR: blue">$polygons</span><span style="COLOR: purple">[] = </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, -</span><span style="COLOR: red">120</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">), </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">), </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, </span><span style="COLOR: red">18</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">),  </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">)
              )</span>;

<span style="COLOR: green">//三侧面点坐标
</span><span style="COLOR: blue">$polygons</span><span style="COLOR: purple">[] = </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, -</span><span style="COLOR: red">120</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">),  </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">),  </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">),</span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, -</span><span style="COLOR: red">120</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">)
              )</span>;
<span style="COLOR: blue">$polygons</span><span style="COLOR: purple">[] = </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, </span><span style="COLOR: red">18</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">),  </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, </span><span style="COLOR: red">18</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">),  </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">)
              )</span>;
<span style="COLOR: blue">$polygons</span><span style="COLOR: purple">[] = </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">),  </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, -</span><span style="COLOR: red">120</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">), </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">0</span><span style="COLOR: purple">, -</span><span style="COLOR: red">120</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">), 
                </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">18</span><span style="COLOR: purple">, -</span><span style="COLOR: red">12</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">),</span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: red">86</span><span style="COLOR: purple">, </span><span style="COLOR: red">48</span><span style="COLOR: purple">, </span><span style="COLOR: red">60</span><span style="COLOR: purple">)
              )</span>;

<span style="COLOR: green">//绘制3D图像
</span><span style="COLOR: blue">foreach </span><span style="COLOR: purple">(</span><span style="COLOR: blue">$polygons as $poly</span><span style="COLOR: purple">) {
    </span><span style="COLOR: blue">$points </span><span style="COLOR: purple">= </span><span style="COLOR: blue">array</span><span style="COLOR: purple">()</span>;
    <span style="COLOR: blue">foreach </span><span style="COLOR: purple">(</span><span style="COLOR: blue">$poly as $set</span><span style="COLOR: purple">) {
        </span><span style="COLOR: blue">$points</span><span style="COLOR: purple">[] = </span><span style="COLOR: blue">new </span>Image_3D_Point<span style="COLOR: purple">(</span><span style="COLOR: blue">$set</span><span style="COLOR: purple">[</span><span style="COLOR: red">0</span><span style="COLOR: purple">], </span><span style="COLOR: blue">$set</span><span style="COLOR: purple">[</span><span style="COLOR: red">1</span><span style="COLOR: purple">], </span><span style="COLOR: blue">$set</span><span style="COLOR: purple">[</span><span style="COLOR: red">2</span><span style="COLOR: purple">])</span>;
    <span style="COLOR: purple">}
    </span><span style="COLOR: blue">$p </span><span style="COLOR: purple">= </span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createObject<span style="COLOR: purple">(</span><span style="COLOR: olive">'polygon'</span><span style="COLOR: purple">, </span><span style="COLOR: blue">$points</span><span style="COLOR: purple">)</span>;
    <span style="COLOR: blue">$p</span><span style="COLOR: purple">-></span>setColor<span style="COLOR: purple">(</span><span style="COLOR: blue">new </span>Image_3D_Color<span style="COLOR: purple">(</span><span style="COLOR: red">255</span><span style="COLOR: purple">, </span><span style="COLOR: red">255</span><span style="COLOR: purple">, </span><span style="COLOR: red">255</span><span style="COLOR: purple">))</span>;
<span style="COLOR: purple">}

</span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>transform<span style="COLOR: purple">(</span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createMatrix<span style="COLOR: purple">(</span><span style="COLOR: olive">'Rotation'</span><span style="COLOR: purple">, </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">10</span><span style="COLOR: purple">, -</span><span style="COLOR: red">25</span><span style="COLOR: purple">, -</span><span style="COLOR: red">15</span><span style="COLOR: purple">)))</span>;
<span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createRenderer<span style="COLOR: purple">(</span><span style="COLOR: olive">'perspectively'</span><span style="COLOR: purple">)</span>;
<span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createDriver<span style="COLOR: purple">(</span><span style="COLOR: olive">'gd'</span><span style="COLOR: purple">)</span>;
<span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>render<span style="COLOR: purple">(</span><span style="COLOR: red">300</span><span style="COLOR: purple">, </span><span style="COLOR: red">300</span><span style="COLOR: purple">, </span><span style="COLOR: olive">'anim.png'</span><span style="COLOR: purple">)</span>;
<span style="COLOR: blue">echo </span><span style="COLOR: olive">'<img  src="anim.png" alt="PHP绘制3D图形之自定义图形及矢量图_PHP" >'</span>;
<span style="COLOR: blue">?></span>
Copy after login

效果图:

矢量图

可缩放的矢量图形(Scalable Vector Graphics,SVG)文件格式是组成2D图像的矢量XML文件。 在2001年,W3C对该格式进行了标准化,但其在Web方面的使用因为浏览器显示SVG文件的牵制而不很流行。 目前,最好的选择是Firefox它有内置的SVG支持,或具有Adobe SVG插件的IE。下面通过一个实例生成SVG文件。

代码:

以下为引用的内容:

<span style="COLOR: blue"><?php
require_once</span><span style="COLOR: purple">(</span><span style="COLOR: olive">'Image/3D.php'</span><span style="COLOR: purple">)</span>;

<span style="COLOR: blue">$rot_x </span><span style="COLOR: purple">= </span><span style="COLOR: red">45</span>;
<span style="COLOR: blue">$rot_y </span><span style="COLOR: purple">= </span><span style="COLOR: red">45</span>;
<span style="COLOR: blue">$rot_z </span><span style="COLOR: purple">= </span><span style="COLOR: red">10</span>;

<span style="COLOR: blue">$image </span><span style="COLOR: purple">= </span><span style="COLOR: blue">new </span>Image_3D<span style="COLOR: purple">()</span>;
<span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>setColor<span style="COLOR: purple">(</span><span style="COLOR: blue">new </span>Image_3D_Color<span style="COLOR: purple">(</span><span style="COLOR: red">255</span><span style="COLOR: purple">, </span><span style="COLOR: red">255</span><span style="COLOR: purple">, </span><span style="COLOR: red">255</span><span style="COLOR: purple">))</span>;

<span style="COLOR: blue">for </span><span style="COLOR: purple">(</span><span style="COLOR: blue">$x</span><span style="COLOR: purple">=</span><span style="COLOR: red">0</span>; <span style="COLOR: blue">$x </span><span style="COLOR: purple">< </span><span style="COLOR: red">4</span>; <span style="COLOR: blue">$x</span><span style="COLOR: purple">++) {
  </span><span style="COLOR: blue">for </span><span style="COLOR: purple">(</span><span style="COLOR: blue">$y</span><span style="COLOR: purple">=</span><span style="COLOR: red">0</span>; <span style="COLOR: blue">$y </span><span style="COLOR: purple">< </span><span style="COLOR: red">4</span>; <span style="COLOR: blue">$y</span><span style="COLOR: purple">++) {
    </span><span style="COLOR: blue">for </span><span style="COLOR: purple">(</span><span style="COLOR: blue">$z</span><span style="COLOR: purple">=</span><span style="COLOR: red">0</span>; <span style="COLOR: blue">$z </span><span style="COLOR: purple">< </span><span style="COLOR: red">4</span>; <span style="COLOR: blue">$z</span><span style="COLOR: purple">++) {
      </span><span style="COLOR: green">//创建球体
      </span><span style="COLOR: blue">$sphere </span><span style="COLOR: purple">= </span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createObject<span style="COLOR: purple">(</span><span style="COLOR: olive">'sphere'</span><span style="COLOR: purple">, </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: olive">'r' </span>=> <span style="COLOR: red">25</span><span style="COLOR: purple">, </span><span style="COLOR: olive">'detail' </span>=> <span style="COLOR: red">3</span><span style="COLOR: purple">))</span>;
      <span style="COLOR: green">//后面150用于设置图像透明度
      </span><span style="COLOR: blue">$sphere</span><span style="COLOR: purple">-></span>setColor<span style="COLOR: purple">(</span><span style="COLOR: blue">new </span>Image_3D_Color<span style="COLOR: purple">(</span><span style="COLOR: red">255</span><span style="COLOR: purple">, </span><span style="COLOR: red">162</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">, </span><span style="COLOR: red">150</span><span style="COLOR: purple">))</span>;
      <span style="COLOR: blue">$sphere</span><span style="COLOR: purple">-></span>transform<span style="COLOR: purple">(</span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createMatrix<span style="COLOR: purple">(</span><span style="COLOR: olive">'Move'</span><span style="COLOR: purple">, </span><span style="COLOR: blue">array</span><span style="COLOR: purple">((</span><span style="COLOR: blue">$x </span><span style="COLOR: purple">* </span><span style="COLOR: red">75</span><span style="COLOR: purple">) + </span><span style="COLOR: red">50</span><span style="COLOR: purple">, </span><span style="COLOR: blue">$y </span><span style="COLOR: purple">* </span><span style="COLOR: red">75</span><span style="COLOR: purple">, </span><span style="COLOR: blue">$z </span><span style="COLOR: purple">* </span><span style="COLOR: red">75</span><span style="COLOR: purple">)))</span>;
      <span style="COLOR: blue">$sphere</span><span style="COLOR: purple">-></span>transform<span style="COLOR: purple">(</span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createMatrix<span style="COLOR: purple">(</span><span style="COLOR: olive">'Rotation'</span><span style="COLOR: purple">, </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(</span><span style="COLOR: blue">$rot_x</span><span style="COLOR: purple">, </span><span style="COLOR: blue">$rot_y</span><span style="COLOR: purple">, </span><span style="COLOR: blue">$rot_z</span><span style="COLOR: purple">)))</span>;
    <span style="COLOR: purple">}
  }
}

</span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>transform<span style="COLOR: purple">(</span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createMatrix<span style="COLOR: purple">(</span><span style="COLOR: olive">'Move'</span><span style="COLOR: purple">, </span><span style="COLOR: blue">array</span><span style="COLOR: purple">(-</span><span style="COLOR: red">225</span><span style="COLOR: purple">, -</span><span style="COLOR: red">100</span><span style="COLOR: purple">, </span><span style="COLOR: red">0</span><span style="COLOR: purple">)))</span>;
<span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createRenderer<span style="COLOR: purple">(</span><span style="COLOR: olive">'perspectively'</span><span style="COLOR: purple">)</span>;
<span style="COLOR: green">//使用SVG驱动生成矢量图
</span><span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>createDriver<span style="COLOR: purple">(</span><span style="COLOR: olive">'svg'</span><span style="COLOR: purple">)</span>;
<span style="COLOR: blue">$image</span><span style="COLOR: purple">-></span>render<span style="COLOR: purple">(</span><span style="COLOR: red">600</span><span style="COLOR: purple">, </span><span style="COLOR: red">600</span><span style="COLOR: purple">, </span><span style="COLOR: olive">'anim.svg'</span><span style="COLOR: purple">)</span>;
header<span style="COLOR: purple">(</span><span style="COLOR: olive">'Location:anim.svg'</span><span style="COLOR: purple">)</span>;
<span style="COLOR: blue">?></span>
Copy after login

效果图:

输出的SVG文件打开后,其格式即为XML:

以下为引用的内容:

<?xml version="1.0" ?>
<span style="COLOR: blue"><</span>!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<span style="COLOR: blue"><</span><span style="COLOR: maroon">svg </span><span style="COLOR: red">xmlns</span><span style="COLOR: blue">="http://www.w3.org/2000/svg" </span><span style="COLOR: red">x</span><span style="COLOR: blue">="0" </span><span style="COLOR: red">y</span><span style="COLOR: blue">="0" </span><span style="COLOR: red">width</span><span style="COLOR: blue">="600" </span><span style="COLOR: red">height</span><span style="COLOR: blue">="600">

    <</span><span style="COLOR: maroon">defs </span><span style="COLOR: red">id</span><span style="COLOR: blue">="defs16387">
    </</span><span style="COLOR: maroon">defs</span><span style="COLOR: blue">>

    <</span><span style="COLOR: maroon">polygon </span><span style="COLOR: red">id</span><span style="COLOR: blue">="background1" </span><span style="COLOR: red">points</span><span style="COLOR: blue">="0,0 600,0 600,600 0,600" 
            </span><span style="COLOR: red">style</span><span style="COLOR: blue">="fill: #ffffff; fill-opacity: 1.00; stroke: none;" />
    <</span><span style="COLOR: maroon">polygon </span><span style="COLOR: red">points</span><span style="COLOR: blue">="325.87,264.90 323.53,258.51 321.87,262.52" 
            </span><span style="COLOR: red">style</span><span style="COLOR: blue">="fill: #ffa200; fill-opacity: 0.41; stroke: none;" />
    <</span><span style="COLOR: maroon">polygon </span><span style="COLOR: red">points</span><span style="COLOR: blue">="319.40,256.07 321.87,262.52 323.53,258.51" 
            </span><span style="COLOR: red">style</span><span style="COLOR: blue">="fill: #ffa200; fill-opacity: 0.41; stroke: none;" />
    </span>... ...
    <span style="COLOR: blue"><</span><span style="COLOR: maroon">polygon </span><span style="COLOR: red">points</span><span style="COLOR: blue">="230.72,174.08 236.47,190.12 226.95,185.47" 
            </span><span style="COLOR: red">style</span><span style="COLOR: blue">="fill: #ffa200; fill-opacity: 0.41; stroke: none;" />
    <</span><span style="COLOR: maroon">polygon </span><span style="COLOR: red">points</span><span style="COLOR: blue">="230.72,174.08 252.69,180.70 236.47,190.12" 
            </span><span style="COLOR: red">style</span><span style="COLOR: blue">="fill: #ffa200; fill-opacity: 0.41; stroke: none;" />
</</span><span style="COLOR: maroon">svg</span><span style="COLOR: blue">></span>
Copy after login

作者: Gnie
出处: {GnieTech} (http://www.cnblogs.com/gnielee/)
版权声明: 本文的版权归作者与博客园共有。转载时须注明本文的详细链接,否则作者将保留追究其法律责任。
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!