| 1 |
wakaba |
1.1 |
#en |
| 2 |
|
|
<span class=secno>4.7.11.1.10. </span>Images |
| 3 |
|
|
#ja |
| 4 |
|
|
<span class=secno>4.7.11.1.10. </span>画像 |
| 5 |
|
|
|
| 6 |
|
|
#en |
| 7 |
wakaba |
1.2 |
To draw images onto the canvas, the <dfn id=dom-context-2d-drawimage |
| 8 |
wakaba |
1.1 |
title=dom-context-2d-drawImage><code>drawImage</code></dfn> method can be |
| 9 |
|
|
used. |
| 10 |
|
|
#ja |
| 11 |
wakaba |
1.2 |
メソッド <dfn id=dom-context-2d-drawimage |
| 12 |
wakaba |
1.1 |
title=dom-context-2d-drawImage><code>drawImage</code></dfn> |
| 13 |
|
|
は画布上に画像を描画するために使用することができます。 |
| 14 |
|
|
|
| 15 |
|
|
#en |
| 16 |
|
|
This method is overloaded with three variants: <code |
| 17 |
|
|
title="">drawImage(<var title="">image</var>, <var title="">dx</var>, <var |
| 18 |
|
|
title="">dy</var>)</code>, <code title="">drawImage(<var |
| 19 |
|
|
title="">image</var>, <var title="">dx</var>, <var title="">dy</var>, <var |
| 20 |
|
|
title="">dw</var>, <var title="">dh</var>)</code>, and <code |
| 21 |
|
|
title="">drawImage(<var title="">image</var>, <var title="">sx</var>, <var |
| 22 |
|
|
title="">sy</var>, <var title="">sw</var>, <var title="">sh</var>, <var |
| 23 |
|
|
title="">dx</var>, <var title="">dy</var>, <var title="">dw</var>, <var |
| 24 |
|
|
title="">dh</var>)</code>. (Actually it is overloaded with six; each of |
| 25 |
|
|
those three can take either an <code><a |
| 26 |
wakaba |
1.2 |
href=#htmlimageelement>HTMLImageElement</a></code> or an <code><a |
| 27 |
|
|
href=#htmlcanvaselement>HTMLCanvasElement</a></code> for the <var |
| 28 |
wakaba |
1.1 |
title="">image</var> argument.) If not specified, the <var |
| 29 |
|
|
title="">dw</var> and <var title="">dh</var> arguments must default to the |
| 30 |
|
|
values of <var title="">sw</var> and <var title="">sh</var>, interpreted |
| 31 |
|
|
such that one CSS pixel in the image is treated as one unit in the canvas |
| 32 |
|
|
coordinate space. If the <var title="">sx</var>, <var title="">sy</var>, |
| 33 |
|
|
<var title="">sw</var>, and <var title="">sh</var> arguments are omitted, |
| 34 |
|
|
they must default to 0, 0, the image's intrinsic width in image pixels, |
| 35 |
|
|
and the image's intrinsic height in image pixels, respectively. |
| 36 |
|
|
#ja |
| 37 |
|
|
このメソッドは、<code |
| 38 |
|
|
title="">drawImage(<var title="">image</var>, <var title="">dx</var>, <var |
| 39 |
|
|
title="">dy</var>)</code>、<code title="">drawImage(<var |
| 40 |
|
|
title="">image</var>, <var title="">dx</var>, <var title="">dy</var>, <var |
| 41 |
|
|
title="">dw</var>, <var title="">dh</var>)</code>、<code |
| 42 |
|
|
title="">drawImage(<var title="">image</var>, <var title="">sx</var>, <var |
| 43 |
|
|
title="">sy</var>, <var title="">sw</var>, <var title="">sh</var>, <var |
| 44 |
|
|
title="">dx</var>, <var title="">dy</var>, <var title="">dw</var>, <var |
| 45 |
|
|
title="">dh</var>)</code> の3通りに多重定義されています。(実際には |
| 46 |
|
|
6通りで、3通りのいずれの場合も、 <var title="">image</var> 引数に |
| 47 |
|
|
<code><a |
| 48 |
wakaba |
1.2 |
href=#htmlimageelement>HTMLImageElement</a></code> か <code><a |
| 49 |
|
|
href=#htmlcanvaselement>HTMLCanvasElement</a></code> |
| 50 |
wakaba |
1.1 |
のいずれかを指定できます。) |
| 51 |
|
|
引数 <var |
| 52 |
|
|
title="">dw</var> および <var title="">dh</var> は、 |
| 53 |
|
|
指定されていない場合、既定値として、 <var title="">sw</var> と |
| 54 |
|
|
<var title="">sh</var> の値を使用し[[MUST:なければなりません]]。 |
| 55 |
|
|
その場合、画像中の 1 CSS 画素が画布座標空間上の1単位として処理されることとなります。 |
| 56 |
|
|
引数 <var title="">sx</var>、<var title="">sy</var>、 |
| 57 |
|
|
<var title="">sw</var>、 <var title="">sh</var> が省略された場合、 |
| 58 |
|
|
それぞれ既定値の 0、0、画像の画素における画像の内在幅、 |
| 59 |
|
|
画像の画素における画像の内在高とし[[MUST:なければなりません]]。 |
| 60 |
|
|
|
| 61 |
|
|
#en |
| 62 |
|
|
The <var title="">image</var> argument must be an instance of an |
| 63 |
wakaba |
1.2 |
<code><a href=#htmlimageelement>HTMLImageElement</a></code> or <code><a |
| 64 |
|
|
href=#htmlcanvaselement>HTMLCanvasElement</a></code>. If the <var |
| 65 |
wakaba |
1.1 |
title="">image</var> is of the wrong type or null, the implementation must |
| 66 |
|
|
raise a <code>TYPE_MISMATCH_ERR</code> exception. |
| 67 |
|
|
#ja |
| 68 |
wakaba |
1.2 |
引数 <var title="">image</var> は <code><a href=#htmlimageelement>HTMLImageElement</a></code> |
| 69 |
wakaba |
1.1 |
または <code><a |
| 70 |
wakaba |
1.2 |
href=#htmlcanvaselement>HTMLCanvasElement</a></code> |
| 71 |
wakaba |
1.1 |
の実現値でなければ[[MUST:なりません]]。 <var |
| 72 |
|
|
title="">image</var> が誤った型や null である場合、実装は |
| 73 |
|
|
<code>TYPE_MISMATCH_ERR</code> 例外を発生させなければ[[MUST:なりません]]。 |
| 74 |
|
|
|
| 75 |
|
|
#en |
| 76 |
|
|
If the <var title="">image</var> argument is an <code><a |
| 77 |
wakaba |
1.2 |
href=#htmlimageelement>HTMLImageElement</a></code> object whose <code |
| 78 |
|
|
title=dom-img-complete><a href=#dom-img-complete>complete</a></code> attribute |
| 79 |
wakaba |
1.1 |
is false, then the implementation must raise an |
| 80 |
|
|
<code>INVALID_STATE_ERR</code> exception. |
| 81 |
|
|
#ja |
| 82 |
|
|
<var title="">image</var> 引数が <code><a |
| 83 |
wakaba |
1.2 |
href=#htmlimageelement>HTMLImageElement</a></code> であって |
| 84 |
wakaba |
1.1 |
<code |
| 85 |
wakaba |
1.2 |
title=dom-img-complete><a href=#dom-img-complete>complete</a></code> 属性が偽である場合、 |
| 86 |
wakaba |
1.1 |
実装は <code>INVALID_STATE_ERR</code> 例外を発生させなければ[[MUST:なりません]]。 |
| 87 |
|
|
|
| 88 |
|
|
#en |
| 89 |
|
|
The source rectangle is the rectangle whose corners are the four points |
| 90 |
|
|
(<var title="">sx</var>, <var title="">sy</var>), (<span><var |
| 91 |
|
|
title="">sx</var>+<var title="">sw</var></span>, <var title="">sy</var>), |
| 92 |
|
|
(<span><var title="">sx</var>+<var title="">sw</var></span>, <span><var |
| 93 |
|
|
title="">sy</var>+<var title="">sh</var></span>), (<var title="">sx</var>, |
| 94 |
|
|
<span><var title="">sy</var>+<var title="">sh</var></span>). |
| 95 |
|
|
#ja |
| 96 |
|
|
原始矩形は、その頂点が4点 |
| 97 |
|
|
(<var title="">sx</var>, <var title="">sy</var>), (<span><var |
| 98 |
|
|
title="">sx</var>+<var title="">sw</var></span>, <var title="">sy</var>), |
| 99 |
|
|
(<span><var title="">sx</var>+<var title="">sw</var></span>, <span><var |
| 100 |
|
|
title="">sy</var>+<var title="">sh</var></span>), (<var title="">sx</var>, |
| 101 |
|
|
<span><var title="">sy</var>+<var title="">sh</var></span>) |
| 102 |
|
|
であるような矩形です。 |
| 103 |
|
|
|
| 104 |
|
|
#en |
| 105 |
|
|
If the source rectangle is not entirely within the source image, or if |
| 106 |
|
|
one of the <var title="">sw</var> or <var title="">sh</var> arguments is |
| 107 |
|
|
zero, the implementation must raise an <code>INDEX_SIZE_ERR</code> |
| 108 |
|
|
|
| 109 |
|
|
exception. |
| 110 |
|
|
#ja |
| 111 |
|
|
原始矩形が原始画像中に完全に収まっていない場合、 |
| 112 |
|
|
または引数 <var title="">sw</var> または <var title="">sh</var> |
| 113 |
|
|
の1つが零である場合、実装は <code>INDEX_SIZE_ERR</code> 例外を発生させなければ[[MUST:なりません]]。 |
| 114 |
|
|
|
| 115 |
|
|
#en |
| 116 |
|
|
The destination rectangle is the rectangle whose corners are the four |
| 117 |
|
|
points (<var title="">dx</var>, <var title="">dy</var>), (<span><var |
| 118 |
|
|
title="">dx</var>+<var title="">dw</var></span>, <var title="">dy</var>), |
| 119 |
|
|
(<span><var title="">dx</var>+<var title="">dw</var></span>, <span><var |
| 120 |
|
|
title="">dy</var>+<var title="">dh</var></span>), (<var title="">dx</var>, |
| 121 |
|
|
<span><var title="">dy</var>+<var title="">dh</var></span>). |
| 122 |
|
|
#ja |
| 123 |
|
|
目的矩形は、その頂点が4点 |
| 124 |
|
|
(<var title="">dx</var>, <var title="">dy</var>), (<span><var |
| 125 |
|
|
title="">dx</var>+<var title="">dw</var></span>, <var title="">dy</var>), |
| 126 |
|
|
(<span><var title="">dx</var>+<var title="">dw</var></span>, <span><var |
| 127 |
|
|
title="">dy</var>+<var title="">dh</var></span>), (<var title="">dx</var>, |
| 128 |
|
|
<span><var title="">dy</var>+<var title="">dh</var></span>) |
| 129 |
|
|
であるような矩形です。 |
| 130 |
|
|
|
| 131 |
|
|
#en |
| 132 |
|
|
When <code title=dom-context-2d-drawImage><a |
| 133 |
wakaba |
1.2 |
href=#dom-context-2d-drawimage>drawImage()</a></code> is invoked, the region of the |
| 134 |
wakaba |
1.1 |
image specified by the source rectangle must be painted on the region of |
| 135 |
|
|
the canvas specified by the destination rectangle, after applying the <a |
| 136 |
wakaba |
1.2 |
href=#transformations title=dom-context-2d-transformation>current |
| 137 |
wakaba |
1.1 |
transformation matrix</a> to the points of the destination rectangle. |
| 138 |
|
|
#ja |
| 139 |
|
|
<code title=dom-context-2d-drawImage><a |
| 140 |
wakaba |
1.2 |
href=#dom-context-2d-drawimage>drawImage()</a></code> が呼び出されたとき、 |
| 141 |
wakaba |
1.1 |
原始矩形で指定される画像上の領域は、 |
| 142 |
|
|
<a |
| 143 |
wakaba |
1.2 |
href=#transformations title=dom-context-2d-transformation>現在変形行列</a>を目的矩形の点に適用した後、 |
| 144 |
wakaba |
1.1 |
目的矩形で指定される画布上の領域に塗られなければ[[MUST:なりません]]。 |
| 145 |
|
|
|
| 146 |
|
|
#en |
| 147 |
wakaba |
1.2 |
<img alt="" src=images/drawImage.png> |
| 148 |
wakaba |
1.1 |
#ja |
| 149 |
wakaba |
1.2 |
<img alt="" src=http://www.whatwg.org/specs/web-apps/current-work/images/drawImage.png> |
| 150 |
wakaba |
1.1 |
|
| 151 |
|
|
#en |
| 152 |
|
|
When a canvas is drawn onto itself, the drawing model |
| 153 |
|
|
requires the source to be copied before the image is drawn back onto the |
| 154 |
|
|
canvas, so it is possible to copy parts of a canvas onto overlapping parts |
| 155 |
|
|
of itself. |
| 156 |
|
|
#ja |
| 157 |
|
|
画布がそれ自体に塗られるとき、この描画モデルに従うと原始画像は画布上に重ねて描画する以前に複写されなければなりませんから、 |
| 158 |
|
|
画布の一部分をそれと重複する部分に複写することが可能です。 |
| 159 |
|
|
|
| 160 |
|
|
#en |
| 161 |
|
|
When the <code title=dom-context-2d-drawImage><a |
| 162 |
wakaba |
1.2 |
href=#dom-context-2d-drawimage>drawImage()</a></code> method is passed, as its <var |
| 163 |
wakaba |
1.1 |
title="">image</var> argument, an animated image, the poster frame of the |
| 164 |
|
|
animation, or the first frame of the animation if there is no poster |
| 165 |
|
|
frame, must be used. |
| 166 |
|
|
#ja |
| 167 |
|
|
<code title=dom-context-2d-drawImage><a |
| 168 |
wakaba |
1.2 |
href=#dom-context-2d-drawimage>drawImage()</a></code> メソッドが <var |
| 169 |
wakaba |
1.1 |
title="">image</var> 引数にアニメーション画像を引き渡されたとき、 |
| 170 |
|
|
そのアニメーションのポスター枠か、ポスター枠がない場合には最初の枠が使用されなければ[[MUST:なりません]]。 |
| 171 |
|
|
|
| 172 |
|
|
#en |
| 173 |
|
|
Images are painted without affecting the current path, and are subject |
| 174 |
wakaba |
1.2 |
to <a href=#shadows title=shadows>shadow effects</a>, <a |
| 175 |
|
|
href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, the |
| 176 |
|
|
<a href=#clipping-region title="clipping region">clipping region</a>, and <a |
| 177 |
|
|
href=#dom-context-2d-globalcompositeoperation |
| 178 |
wakaba |
1.1 |
title=dom-context-2d-globalCompositeOperation>global composition |
| 179 |
|
|
operators</a>. |
| 180 |
|
|
#ja |
| 181 |
wakaba |
1.2 |
画像は現在経路に影響せずに塗られ、<a href=#shadows title=shadows>影効果</a>、 |
| 182 |
wakaba |
1.1 |
<a |
| 183 |
wakaba |
1.2 |
href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>大域アルファ</a>、 |
| 184 |
|
|
<a href=#clipping-region title="clipping region">くり抜き領域</a>、 |
| 185 |
wakaba |
1.1 |
<a |
| 186 |
wakaba |
1.2 |
href=#dom-context-2d-globalcompositeoperation |
| 187 |
wakaba |
1.1 |
title=dom-context-2d-globalCompositeOperation>大域合成操作</a>の対象でもあります。 |
| 188 |
|
|
|