aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/path2d
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/path2d
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/api/path2d')
-rw-r--r--files/ja/web/api/path2d/addpath/index.html131
-rw-r--r--files/ja/web/api/path2d/index.html139
-rw-r--r--files/ja/web/api/path2d/path2d/index.html109
3 files changed, 379 insertions, 0 deletions
diff --git a/files/ja/web/api/path2d/addpath/index.html b/files/ja/web/api/path2d/addpath/index.html
new file mode 100644
index 0000000000..8cbf67ef2f
--- /dev/null
+++ b/files/ja/web/api/path2d/addpath/index.html
@@ -0,0 +1,131 @@
+---
+title: Path2D.addPath()
+slug: Web/API/Path2D/addPath
+translation_of: Web/API/Path2D/addPath
+---
+<div>{{APIRef("Canvas API")}}</div>
+
+<p>Canvas 2D APIの<code><strong>Path2D</strong></code><strong><code>.addPath()</code></strong>メソッドは、パスに対して引数でパスを追加します。</p>
+
+<h2 id="構文">構文</h2>
+
+<pre class="syntaxbox">void <var><em>path</em>.addPath(path [, transform]);</var>
+</pre>
+
+<h3 id="パラメーター">パラメーター</h3>
+
+<dl>
+ <dt><code>path</code></dt>
+ <dd>追加する{{domxref("Path2D")}}パス</dd>
+ <dt><code>transform</code> {{optional_inline}}</dt>
+ <dd>パスに追加する変換マトリックスとして使われる{{domxref("SVGMatrix")}}.</dd>
+</dl>
+
+<h2 id="例">例</h2>
+
+<h3 id="addPathメソッドを使用する"><code>addPathメソッドを使用する</code></h3>
+
+<p>これは<code>addPathメソッドを使用する簡単なコードスニペットです。</code></p>
+
+<pre class="brush: js; highlight:[19]">var canvas = document.getElementById("canvas");
+var ctx = canvas.getContext("2d");
+
+// rectで新しいパスを作成する
+var p1 = new Path2D();
+p1.rect(0,0,100,100);
+
+// rectで別のパスを作成する
+var p2 = new Path2D();
+p2.rect(0,0,100,100);
+
+// 右に縦300ポイント移動する変換マトリックスを作成する
+var m = document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGMatrix();
+m.a = 1; m.b = 0;
+m.c = 0; m.d = 1;
+m.e = 300; m.f = 0;
+
+// 2番目のパスを最初のパスに追加する
+p1.addPath(p2, m);
+
+// 最後に、1番目のパスをキャンバスに描画する
+ctx.fill(p1);
+</pre>
+
+<p>以下のコードを編集して、その変更が canvas に反映されることを確かめてください(現在のブラウザーが実際にこのメソッドをサポートしているか、以下のブラウザー互換テーブルをチェックしてください)</p>
+
+<p>{{ EmbedLiveSample('Playable_code', 700, 500) }}</p>
+
+<h2 id="仕様">仕様</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', "scripting.html#dom-path2d-addpath", "Path2D.addPath()")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>初期定義</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="ブラウザー互換性">ブラウザー互換性</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<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>{{CompatNo}}</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>Chrome for 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>{{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("Path2D")}}に定義されています。</li>
+</ul>
diff --git a/files/ja/web/api/path2d/index.html b/files/ja/web/api/path2d/index.html
new file mode 100644
index 0000000000..2048feff2e
--- /dev/null
+++ b/files/ja/web/api/path2d/index.html
@@ -0,0 +1,139 @@
+---
+title: Path2D
+slug: Web/API/Path2D
+tags:
+ - API
+ - Canvas
+ - Interface
+ - NeedsTranslation
+ - Path2D
+ - Reference
+ - TopicStub
+translation_of: Web/API/Path2D
+---
+<div>{{APIRef("Canvas API")}} {{SeeCompatTable}}</div>
+
+<p>The <strong><code>Path2D</code></strong> interface of the Canvas 2D API is used to declare paths that are then later used on {{domxref("CanvasRenderingContext2D")}} objects. The<a href="/en-US/docs/Web/API/CanvasRenderingContext2D#Paths"> path methods</a> of the <code>CanvasRenderingContext2D</code> interface are present on this interface as well and are allowing you to create paths that you can retain and replay as required on a canvas.</p>
+
+<h2 id="Constructors">Constructors</h2>
+
+<dl>
+ <dt>{{domxref("Path2D.Path2D", "Path2D()")}}</dt>
+ <dd><code>Path2D</code> constructor. Creates a new <code>Path2D</code> object.</dd>
+</dl>
+
+<h2 id="Methods">Methods</h2>
+
+<dl>
+ <dt>{{domxref("Path2D.addPath()")}}</dt>
+ <dd>Adds a path to the current path.</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.closePath", "Path2D.closePath()")}}</dt>
+ <dd>Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing.</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.moveTo()", "Path2D.moveTo()")}}</dt>
+ <dd>Moves the starting point of a new sub-path to the <strong>(x, y)</strong> coordinates.</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.lineTo()", "Path2D.lineTo()")}}</dt>
+ <dd>Connects the last point in the subpath to the <code>x, y</code> coordinates with a straight line.</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.bezierCurveTo()", "Path2D.bezierCurveTo()")}}</dt>
+ <dd>Adds a cubic Bézier curve to the path. It requires three points. The first two points are control points and the third one is the end point. The starting point is the last point in the current path, which can be changed using <code>moveTo()</code> before creating the Bézier curve.</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.quadraticCurveTo()", "Path2D.quadraticCurveTo()")}}</dt>
+ <dd>Adds a quadratic Bézier curve to the current path.</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.arc()", "Path2D.arc()")}}</dt>
+ <dd>Adds an arc to the path which is centered at <em>(x, y)</em> position with radius<em> r</em> starting at <em>startAngle</em> and ending at <em>endAngle</em> going in the given direction by <em>anticlockwise</em> (defaulting to clockwise).</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.arcTo()", "Path2D.arcTo()")}}</dt>
+ <dd>Adds an arc to the path with the given control points and radius, connected to the previous point by a straight line.</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.ellipse()", "Path2D.ellipse()")}}</dt>
+ <dd>Adds an ellipse to the path which is centered at <em>(x, y)</em> position with the radii <em>radiusX</em> and <em>radiusY</em> starting at <em>startAngle</em> and ending at <em>endAngle</em> going in the given direction by <em>anticlockwise</em> (defaulting to clockwise).</dd>
+ <dt>{{domxref("CanvasRenderingContext2D.rect()", "Path2D.rect()")}}</dt>
+ <dd>Creates a path for a rectangle at<em> </em>position <em>(x, y)</em> with a size that is determined by <em>width</em> and <em>height</em>.</dd>
+</dl>
+
+<h2 id="Specifications" name="Specifications">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="Browser_compatibility">Browser compatibility</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="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("CanvasRenderingContext2D")}}</li>
+</ul>
diff --git a/files/ja/web/api/path2d/path2d/index.html b/files/ja/web/api/path2d/path2d/index.html
new file mode 100644
index 0000000000..2a4fbfa4da
--- /dev/null
+++ b/files/ja/web/api/path2d/path2d/index.html
@@ -0,0 +1,109 @@
+---
+title: Path2D()
+slug: Web/API/Path2D/Path2D
+tags:
+ - API
+ - Canvas
+ - Constructor
+ - Drawing
+ - Graphics
+ - Path2D
+ - Paths
+ - Reference
+translation_of: Web/API/Path2D/Path2D
+---
+<div>{{APIRef("Canvas API")}}{{seeCompatTable}}</div>
+
+<p><code><strong>Path2D()</strong></code> コンストラクターは、新たにインスタンス化した <code>Path2D</code> オブジェクトを返します。他のパスを引数に渡すこともできます(複製がつくられます)。また、<a href="/ja/docs/Web/SVG/Tutorial/Paths">SVG パス</a> からなるデータを文字列で渡すこともできます。</p>
+
+<h2 id="Syntax" name="Syntax">構文</h2>
+
+<pre class="syntaxbox">new Path2D();
+new Path2D(<em>path</em>);
+new Path2D(<em>d</em>);
+</pre>
+
+<h3 id="Parameters" name="Parameters">引数</h3>
+
+<dl>
+ <dt><code>path</code> {{optional_inline}}</dt>
+ <dd>他の<code>Path2D</code> オブジェクトを渡して呼び出すと、引数の <code>path</code> が複製されます。</dd>
+ <dt><code>d</code> {{optional_inline}}</dt>
+ <dd><a href="/ja/docs/Web/SVG/Tutorial/Paths">SVG パス</a> からなる文字列を渡して呼出すと、その内容のパスが新たにつくられます。</dd>
+</dl>
+
+<dl>
+</dl>
+
+<h2 id="Examples" name="Examples">例</h2>
+
+<h3 id="Creating_and_copying_paths" name="Creating_and_copying_paths">パスを複製してつくる</h3>
+
+<p>これは、<code>Path2D</code> のパスを複製して作成する簡単なコードスニペットです。</p>
+
+<div class="hidden">
+<pre class="brush: html">&lt;canvas id="canvas"&gt;&lt;/canvas&gt;</pre>
+</div>
+
+<pre class="brush: js; highlight:[4,7]">const canvas = document.getElementById('canvas');
+const ctx = canvas.getContext('2d');
+
+let path1 = new Path2D();
+path1.rect(10, 10, 100,100);
+
+let path2 = new Path2D(path1);
+path2.moveTo(220, 60);
+path2.arc(170, 60, 50, 0, 2 * Math.PI);
+
+ctx.stroke(path2);
+</pre>
+
+<p>{{ EmbedLiveSample('Creating_and_copying_paths', 700, 180) }}</p>
+
+<h3 id="Using_SVG_paths" name="Using_SVG_paths">SVG パスを使用する</h3>
+
+<p>これは、<a href="/docs/Web/SVG/Tutorial/Paths">SVG パスデータ</a> を使用して <code>Path2D</code> のパスを作成する簡単なコードスニペットです。パスは点 (<code>M10 10</code>) に移ってから、水平に 80 ポイント右に移動し (<code>h 80</code>)、80 ポイント下がり (<code>v 80</code>)、80ポイント左に移動し (<code>h -80</code>)、開始点に戻ります (<code>z</code>)。</p>
+
+<div class="hidden">
+<pre class="brush: html">&lt;canvas id="canvas"&gt;&lt;/canvas&gt;</pre>
+</div>
+
+<pre class="brush: js; highlight:[4]">const canvas = document.getElementById('canvas');
+const ctx = canvas.getContext('2d');
+
+let p = new Path2D('M10 10 h 80 v 80 h -80 Z');
+ctx.fill(p);
+</pre>
+
+<p>{{ EmbedLiveSample('Using_SVG_paths', 700, 180) }}</p>
+
+<h2 id="Specification" name="Specification">仕様</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', '#dom-path2d', 'Path2D()')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2>
+
+<div>
+
+
+<p>{{Compat("api.Path2D")}}</p>
+</div>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li>{{domxref("Path2D")}} インタフェースに、このコンストラクタは属します。</li>
+</ul>