Heim Backend-Entwicklung PHP-Tutorial PHP绘制3D图形之自定义图形及矢量图_PHP

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

Jun 01, 2016 pm 12:21 PM

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

自定义多边形

代码:

以下为引用的内容:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

<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="/static/imghw/default1.png"  data-src="anim.png"  class="lazy" alt="PHP绘制3D图形之自定义图形及矢量图_PHP" >'</span>;

<span style="COLOR: blue">?></span>

Nach dem Login kopieren

效果图:

矢量图

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

代码:

以下为引用的内容:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

<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>

Nach dem Login kopieren

效果图:

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

以下为引用的内容:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<?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>

Nach dem Login kopieren

作者: Gnie
出处: {GnieTech} (http://www.cnblogs.com/gnielee/)
版权声明: 本文的版权归作者与博客园共有。转载时须注明本文的详细链接,否则作者将保留追究其法律责任。
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

Video Face Swap

Video Face Swap

Tauschen Sie Gesichter in jedem Video mühelos mit unserem völlig kostenlosen KI-Gesichtstausch-Tool aus!

Heiße Werkzeuge

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools

SublimeText3 Mac-Version

SublimeText3 Mac-Version

Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Wie funktioniert die Session -Entführung und wie können Sie es in PHP mildern? Wie funktioniert die Session -Entführung und wie können Sie es in PHP mildern? Apr 06, 2025 am 12:02 AM

Die Hijacking der Sitzung kann in den folgenden Schritten erreicht werden: 1. Erhalten Sie die Sitzungs -ID, 2. Verwenden Sie die Sitzungs -ID, 3. Halten Sie die Sitzung aktiv. Zu den Methoden zur Verhinderung der Sitzung der Sitzung in PHP gehören: 1. Verwenden Sie die Funktion Session_regenerate_id (), um die Sitzungs -ID zu regenerieren. 2. Store -Sitzungsdaten über die Datenbank, 3. Stellen Sie sicher, dass alle Sitzungsdaten über HTTPS übertragen werden.

Erklären Sie JSON Web Tokens (JWT) und ihren Anwendungsfall in PHP -APIs. Erklären Sie JSON Web Tokens (JWT) und ihren Anwendungsfall in PHP -APIs. Apr 05, 2025 am 12:04 AM

JWT ist ein offener Standard, der auf JSON basiert und zur sicheren Übertragung von Informationen zwischen Parteien verwendet wird, hauptsächlich für die Identitätsauthentifizierung und den Informationsaustausch. 1. JWT besteht aus drei Teilen: Header, Nutzlast und Signatur. 2. Das Arbeitsprinzip von JWT enthält drei Schritte: Generierung von JWT, Überprüfung von JWT und Parsingnayload. 3. Bei Verwendung von JWT zur Authentifizierung in PHP kann JWT generiert und überprüft werden, und die Funktionen und Berechtigungsinformationen der Benutzer können in die erweiterte Verwendung aufgenommen werden. 4. Häufige Fehler sind Signaturüberprüfungsfehler, Token -Ablauf und übergroße Nutzlast. Zu Debugging -Fähigkeiten gehört die Verwendung von Debugging -Tools und Protokollierung. 5. Leistungsoptimierung und Best Practices umfassen die Verwendung geeigneter Signaturalgorithmen, das Einstellen von Gültigkeitsperioden angemessen.

Wie debugge ich den CLI -Modus in PhpStorm? Wie debugge ich den CLI -Modus in PhpStorm? Apr 01, 2025 pm 02:57 PM

Wie debugge ich den CLI -Modus in PhpStorm? Bei der Entwicklung mit PHPSTORM müssen wir manchmal den PHP im CLI -Modus (COMS -Zeilenschnittstellen) debuggen ...

Beschreiben Sie die soliden Prinzipien und wie sie sich für die PHP -Entwicklung anwenden. Beschreiben Sie die soliden Prinzipien und wie sie sich für die PHP -Entwicklung anwenden. Apr 03, 2025 am 12:04 AM

Die Anwendung des soliden Prinzips in der PHP -Entwicklung umfasst: 1. Prinzip der Einzelverantwortung (SRP): Jede Klasse ist nur für eine Funktion verantwortlich. 2. Open and Close Principle (OCP): Änderungen werden eher durch Erweiterung als durch Modifikation erreicht. 3.. Lischs Substitutionsprinzip (LSP): Unterklassen können Basisklassen ersetzen, ohne die Programmgenauigkeit zu beeinträchtigen. 4. Schnittstellen-Isolationsprinzip (ISP): Verwenden Sie feinkörnige Schnittstellen, um Abhängigkeiten und nicht verwendete Methoden zu vermeiden. 5. Abhängigkeitsinversionsprinzip (DIP): Hoch- und niedrige Module beruhen auf der Abstraktion und werden durch Abhängigkeitsinjektion implementiert.

Wie setze ich nach dem Neustart des Systems automatisch Berechtigungen von Unixsocket fest? Wie setze ich nach dem Neustart des Systems automatisch Berechtigungen von Unixsocket fest? Mar 31, 2025 pm 11:54 PM

So setzen Sie die Berechtigungen von Unixsocket automatisch nach dem Neustart des Systems. Jedes Mal, wenn das System neu startet, müssen wir den folgenden Befehl ausführen, um die Berechtigungen von Unixsocket: sudo ...

Erklären Sie die späte statische Bindung in PHP (statisch: :). Erklären Sie die späte statische Bindung in PHP (statisch: :). Apr 03, 2025 am 12:04 AM

Statische Bindung (statisch: :) implementiert die späte statische Bindung (LSB) in PHP, sodass das Aufrufen von Klassen in statischen Kontexten anstatt Klassen zu definieren. 1) Der Analyseprozess wird zur Laufzeit durchgeführt.

Rahmensicherheitsmerkmale: Schutz vor Schwachstellen. Rahmensicherheitsmerkmale: Schutz vor Schwachstellen. Mar 28, 2025 pm 05:11 PM

In Artikel werden wichtige Sicherheitsfunktionen in Frameworks erörtert, um vor Schwachstellen zu schützen, einschließlich Eingabevalidierung, Authentifizierung und regelmäßigen Aktualisierungen.

See all articles