SVG

SVG和Canvas的区别? SVG使用XML语言, 会创建dom, 是矢量图, 不适合游戏. 而Canvas使用js操作, 不会创建dom, 是像素图.

<html>
<body>
<h1>My first SVG</h1>
/*定义svg画布的尺寸*/
  <svg width="100" height="100">
  /*绘制圆形*/
    <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
  </svg>      
</body>
</html>

矩形

<svg width="400" height="100">
  <rect width="400" height="100" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>

圆角矩形

<svg width="400" height="180">
  <rect x="50" y="20" rx="20" ry="20" width="150" height="150"
  style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>

results matching ""

    No results matching ""