WebGLRenderingContext.blendColor()

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.

WebGL APIWebGLRenderingContext.blendColor() 方法用于设置源和目标混合因子。

语法

void gl.blendColor(red, green, blue, alpha);

参数

red

GLclampf 红色分量的范围为 0 到 1。

green

GLclampf 红色分量的范围为 0 到 1。

blue

GLclampf 红色分量的为 0 到 1。

alpha

GLclampf 组件(透明度)的范围在 0 到 1。

返回值

None.

示例

要设置混合颜色,请使用:

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

要获得混合颜色,请查询返回 Float32Array 的 BLEND_COLOR 常量。

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

规范

Specification
WebGL Specification
# 5.14.3

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
blendColor

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见