diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/webglrenderingcontext/scissor/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/webglrenderingcontext/scissor/index.html')
-rw-r--r-- | files/zh-cn/web/api/webglrenderingcontext/scissor/index.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglrenderingcontext/scissor/index.html b/files/zh-cn/web/api/webglrenderingcontext/scissor/index.html new file mode 100644 index 0000000000..87c080f3ba --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/scissor/index.html @@ -0,0 +1,94 @@ +--- +title: WebGLRenderingContext.scissor() +slug: Web/API/WebGLRenderingContext/scissor +tags: + - WebGL +translation_of: Web/API/WebGLRenderingContext/scissor +--- +<div>{{APIRef("WebGL")}}</div> + +<p> <strong><code>WebGLRenderingContext.scissor()</code></strong> 方法指定了一个裁剪区域,用来将绘图区域限制在其限定的盒形区域内。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox notranslate"><var><em>void gl</em>.</var>scissor<var>(x, y, width, height);</var> +</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>x</code></dt> + <dd>{{domxref("GLint")}} ,指定盒形裁剪区域左下角所在的横坐标,默认为 0。</dd> + <dt><code>y</code></dt> + <dd> {{domxref("GLint")}} 指定盒形裁剪区域左下角的纵坐标,默认为 0。</dd> + <dt>width</dt> + <dd>{{domxref("Glsizei")}},用来确定盒型裁剪区域宽度的非负数,默认为 canvas 的宽度。</dd> + <dt>height</dt> + <dd>{{domxref("Glsizei")}} ,用以指定盒形裁剪区域高度的非负数,默认为canvas 的高度。</dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p>无。</p> + +<h3 id="抛错">抛错</h3> + +<p>宽或高为负值时,抛出 <code>gl.INVALID_VALUE</code> 错误。</p> + +<h2 id="示例">示例</h2> + +<p>当裁剪区域可用的时候,只有处于此区域内的像素才能由绘图命令修改。</p> + +<pre class="brush: js notranslate">// turn on scissor test +gl.enable(gl.SCISSOR_TEST); + +// set the scissor rectangle +gl.scissor(x, y, width, height); + +// execute drawing commands in the scissor box (e.g. clear) + +// turn off scissor test again +gl.disable(gl.SCISSOR_TEST); +</pre> + +<p>通过查询 <code>SCISSOR_BOX</code> 常量来获取裁剪区域的维度信息,返回值是一个 {{jsxref("Int32Array")}} 对象。</p> + +<pre class="brush: js notranslate">gl.scissor(0, 0, 200, 200); +gl.getParameter(gl.SCISSOR_BOX); +// Int32Array[0, 0, 200, 200]</pre> + +<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('WebGL', "#5.14.4", "scissor")}}</td> + <td>{{Spec2('WebGL')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('OpenGL ES 2.0', "glScissor.xml", "glScissor")}}</td> + <td>{{Spec2('OpenGL ES 2.0')}}</td> + <td>Man page of the OpenGL API.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("api.WebGLRenderingContext.scissor")}}</p> + +<h2 id="参见">参见</h2> + +<ul> + <li>{{domxref("WebGLRenderingContext.viewport()")}}</li> + <li>{{domxref("WebGLRenderingContext.enable()")}}</li> + <li>{{domxref("WebGLRenderingContext.disable()")}}</li> +</ul> |