glctx.ClearColor 参数说明

glctx.ClearColor 的参数信息如下:

// ClearColor specifies the RGBA values used to clear color buffers.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glClearColor.xhtml
ClearColor(red, green, blue, alpha float32)
这四个参数指定由glClear清除颜色缓存时所使用的红、绿、蓝和alpha值,指定值的范围固定为[0.0f,1.0f]。 
red, green, blue, alpha

Specify the red, green, blue, and alpha values used when the color buffers are cleared. The initial values are all 0.

在 Photoshop 中获得这个值,需要用到颜色取样器,这个工具所在的位置如下图:

image

选择我们需要观察的点,就会看到下面的信息。

image

在ClearColor中使用的,注意参数的取值范围, 即,我们需要如下来写:

glctx.ClearColor(171.0/255.0, 190.0/255.0, 62.0/255.0, 1)
glctx.Clear(gl.COLOR_BUFFER_BIT)

注意不要是 171/255 这样无法计算出小数。

 

alpha通道一般用作不透明度参数。如果一个像素的alpha通道数值为0%,那它就是完全透明的(也就是看不见的),而数值为100%则意味着一个完全不透明的像素(传统的数字图像)。在0%和100%之间的值则使得像素可以透过背景显示出来,就像透过玻璃(半透明性),这种效果是简单的二元透明性(透明或不透明)做不到的。它使数码合成变得容易。alpha通道值可以用百分比、整数或者像RGB参数那样用0到1的实数表示。

 

参考:

http://bbs.tairan.com/article-11-2.html

https://zh.wikipedia.org/wiki/RGBA

原文地址:https://www.cnblogs.com/ghj1976/p/5374605.html