--- title: WebGLRenderingContext.blendColor() slug: Web/API/WebGLRenderingContext/blendColor tags: - API - Method - Reference - WebGL - WebGLRenderingContext translation_of: Web/API/WebGLRenderingContext/blendColor ---
WebGL API 的 WebGLRenderingContext.blendColor()
方法用于设置源和目标混合因子。
void gl.blendColor(red, green, blue, alpha);
red
green
None.
要设置混合颜色,请使用:
gl.blendColor(0, 0.5, 1, 1);
要获得混合颜色,请查询返回 {{jsxref("Float32Array")}} 的 BLEND_COLOR 常量。
gl.getParameter(gl.BLEND_COLOR); // Float32Array[0, 0.5, 1, 1]
Specification | Status | Comment |
---|---|---|
{{SpecName('WebGL', "#5.14.3", "blendColor")}} | {{Spec2('WebGL')}} | Initial definition. |
{{SpecName('OpenGL ES 2.0', "glBlendColor.xml", "glBlendColor")}} | {{Spec2('OpenGL ES 2.0')}} | Man page of the OpenGL API. |
{{Compat("api/WebGLRenderingContext", "WebGLRenderingContext.blendColor")}}