Name |
blue()蓝色值 |
||||
Examples |
color c = color(175, 100, 220); // Define color ‘c’ fill(c); // Use color variable ‘c’ as fill color rect(15, 20, 35, 60); // Draw left rectangle
float blueValue = blue(c); // Get blue in ‘c’ println(blueValue); // Prints “220.0” fill(0, 0, blueValue); // Use ‘blueValue’ in new fill rect(50, 20, 35, 60); // Draw right rectangle |
||||
Description |
Extracts the blue value from a color, scaled to match current colorMode(). The value is always returned as a float, so be careful not to assign it to an int value. The blue() function is easy to use and understand, but it is slower than a technique called bit masking. When working in colorMode(RGB, 255), you can acheive the same results as blue() but with greater speed by using a bit mask to remove the other color components. For example, the following two lines of code are equivalent means of getting the blue value of the color value c: 从颜色中提取蓝色值, 缩放以匹配当前 colorMode ()。该值始终作为浮点返回, 因此请注意不要将其赋给一个 int 值。
蓝色 () 函数易于使用和理解, 但它比称为比特掩蔽的技术慢。在 colorMode (RGB、255) 中工作时, 可以通过使用位掩码移除其他颜色组件来获得与蓝色 () 相同的结果, 但速度更大。例如, 以下两行代码是获取颜色值 c 的蓝色值的等效方法:
float b1 = blue(c); // Simpler, but slower to calculate 简单,但是慢 float b2 = c & 0xFF; // Very fast to calculate 非常快 |
||||
Syntax |
blue(rgb) |
||||
Parameters |
|
||||
Returns |
float |
||||
Related |
red() |
- 本文固定链接: http://iprocessing.cn/2017/08/08/blue蓝色值/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表