WebGLRenderingContext.drawingBufferWidth
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
WebGLRenderingContext.drawingBufferWidth
只读属性,指示当前绘图缓冲区的实际宽度。它应当匹配与绘图上下文相关联的 <canvas>
元素的宽度属性。如果实现未能提供所要求的宽度,值将有所不同。
语法
gl.drawingBufferWidth;
示例
指定<canvas>
元素:
html
<canvas id="canvas"></canvas>
你可以通过下面几行代码来获取绘图缓冲区的宽度:
js
var canvas = document.getElementById("canvas");
var gl = canvas.getContext("webgl");
gl.drawingBufferWidth; // 300
规范
Specification |
---|
WebGL Specification # DOM-WebGLRenderingContext-drawingBufferWidth |
浏览器兼容性
BCD tables only load in the browser