WebGL
WebGL API 的 WebGLRenderingContext.blendColor() 方法用于设置源和目标混合因子。
语法
blendColor(red, green, blue, alpha)
参数
red- : WebGL_API/Types,表示红色分量,范围为 0 到 1。默认值为 0。
green- : WebGL_API/Types,表示绿色分量,范围为 0 到 1。默认值为 0。
blue- : WebGL_API/Types,表示蓝色分量,范围为 0 到 1。默认值为 0。
alpha- : WebGL_API/Types,表示 alpha 分量(透明度),范围为 0 到 1。默认值为 0。
返回值
无(undefined)。
示例
要设置混合颜色,请使用:
gl.blendColor(0, 0.5, 1, 1);
要获取混合颜色,可以查询 BLEND_COLOR 常量,它会返回一个 Float32Array。
gl.getParameter(gl.BLEND_COLOR);
// Float32Array[0, 0.5, 1, 1]
规范
浏览器兼容性
参见
- WebGLRenderingContext.blendEquation()
- WebGLRenderingContext.blendFunc()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
