WebGLRenderingContext: blendColor() 方法

基线 广泛可用

此功能已久经考验,可在许多设备和浏览器版本上运行。 它自 2015 年 7 月.

报告反馈

语法

js
blendColor(red, green, blue, alpha)

参数

red

A GLclampf for the red component in the range of 0 to 1. Default value is 0.

green

A GLclampf for the green component in the range of 0 to 1. Default value is 0.

blue

A GLclampf for the blue component in the range of 0 to 1. Default value is 0.

alpha

A GLclampf for the alpha component (transparency) in the range of 0. to 1. Default value is 0.

返回值

None (undefined).

示例

To set the blend color, use

js
gl.blendColor(0, 0.5, 1, 1);

To get the blend color, query the BLEND_COLOR constant which returns a Float32Array.

js
gl.getParameter(gl.BLEND_COLOR);
// Float32Array[0, 0.5, 1, 1]

规范

规范
WebGL 规范
# 5.14.3

浏览器兼容性

BCD 表格仅在启用 JavaScript 的浏览器中加载。

另请参阅