aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/path2d/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/path2d/index.html')
-rw-r--r--files/zh-cn/web/api/path2d/index.html131
1 files changed, 131 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/path2d/index.html b/files/zh-cn/web/api/path2d/index.html
new file mode 100644
index 0000000000..b27962c96c
--- /dev/null
+++ b/files/zh-cn/web/api/path2d/index.html
@@ -0,0 +1,131 @@
+---
+title: Path2D
+slug: Web/API/Path2D
+translation_of: Web/API/Path2D
+---
+<div>{{APIRef("Canvas API")}} {{SeeCompatTable}}</div>
+
+<p>Canvas 2D API 的接口 <strong><code>Path2D</code></strong> 用来声明路径,此路径稍后会被{{domxref("CanvasRenderingContext2D")}} 对象使用。<code style="font-style: normal;">CanvasRenderingContext2D</code> 接口的 <a href="/en-US/docs/Web/API/CanvasRenderingContext2D#Paths">路径方法</a> 也存在于 Path2D 这个接口中,允许你在 canvas 中根据需要创建可以保留并重用的路径。</p>
+
+<h2 id="构造函数">构造函数</h2>
+
+<dl>
+ <dt>{{domxref("Path2D.Path2D", "Path2D()")}}</dt>
+ <dd><code>Path2D</code> 构造函数。 创建一个新的 <code>Path2D</code> 对象。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{domxref("Path2D.addPath()")}}</dt>
+ <dd>添加一条新路径到对当前路径。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.closePath", "Path2D.closePath()")}}</dt>
+ <dd>使笔点返回到当前子路径的起始点。它尝试从当前点到起始点绘制一条直线。 如果图形已经是封闭的或者只有一个点,那么此函数不会做任何操作。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.moveTo()", "Path2D.moveTo()")}}</dt>
+ <dd>将一个新的子路径的起始点移动到(x,y)坐标。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.lineTo()", "Path2D.lineTo()")}}</dt>
+ <dd>使用直线连接子路径的终点到 <code style="font-style: normal;">x, y</code>  坐标。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.bezierCurveTo()", "Path2D.bezierCurveTo()")}}</dt>
+ <dd>添加一条三次贝赛尔曲线到当前路径。 该方法需要三个点。 第一、第二个点是控制点,第三个点是结束点。起始点是当前路径的最后一个点,绘制贝赛尔曲线前,可以通过调用 <code style="font-style: normal;">moveTo()</code> 进行修改。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.quadraticCurveTo()", "Path2D.quadraticCurveTo()")}}</dt>
+ <dd>添加一条二次贝赛尔曲线到当前路径。 </dd>
+ <dt>{{domxref("CanvasRenderingContext2D.arc()", "Path2D.arc()")}}</dt>
+ <dd>添加一条圆弧路径。 圆弧路径的圆心在 <em>(x, y)</em> 位置,半径为<em> r</em> ,根据<em>anticlockwise</em> (默认为顺时针)指定的方向从 <em>startAngle</em> 开始绘制,到 <em>endAngle</em> 结束。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.arcTo()", "Path2D.arcTo()")}}</dt>
+ <dd>根据控制点和半径添加一条圆弧路径,使用直线连接前一个点。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.ellipse()", "Path2D.ellipse()")}}</dt>
+ <dd>添加一条椭圆路径。椭圆的圆心在(x,y)位置,半径分别是<em>radiusX</em> 和 <em>radiusY</em> ,按照<em>anticlockwise</em> (默认顺时针)指定的方向,从 <em>startAngle </em> 开始绘制,到 <em>endAngle</em> 结束。</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.rect()", "Path2D.rect()")}}</dt>
+ <dd>创建一条矩形路径,矩形的起点位置是 <em>(x, y) </em>,尺寸为 <em>width</em> 和 <em>height</em>。</dd>
+</dl>
+
+<h2 id="Specifications" name="Specifications">规范描述</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', "scripting.html#dom-path2d", "Path2D")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("31")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td>{{domxref("Path2D.addPath()")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("34")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("31")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td>{{domxref("Path2D.addPath()")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("34")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{domxref("CanvasRenderingContext2D")}}</li>
+</ul>