We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

WebGLRenderingContext.drawingBufferWidth

WebGLRenderingContext.drawingBufferWidth 只读属性, 指示当前绘图缓冲区的实际宽度。它应当匹配与绘图上下文相关联的 <canvas> 元素的宽度属性。如果实现未能提供所要求的宽度,值将有所不同。

句法

gl.drawingBufferWidth;

示例

指定<canvas> 元素:

<canvas id="canvas"></canvas>

你可以通过下面几行代码来获取绘图缓冲区的宽度:

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
gl.drawingBufferWidth; // 300

规范

Specification Status Comment
WebGL 1.0
WebGLRenderingContext.drawingBufferWidth
Recommendation Initial definition.

浏览器兼容性

No compatibility data found. Please contribute data for "api/WebGLRenderingContext" (depth: WebGLRenderingContext.drawingBufferWidth) to the MDN compatibility data repository.

另见

文档标签和贡献者

此页面的贡献者: luojia, LiebeU
最后编辑者: luojia,