Name |
tint()设置图像填充色 |
||||||||||||
Examples |
PImage img; img = loadImage(“laDefense.jpg”); image(img, 0, 0); tint(0, 153, 204); // Tint blue image(img, 50, 0);
PImage img; img = loadImage(“laDefense.jpg”); image(img, 0, 0); tint(0, 153, 204, 126); // Tint blue and set transparency image(img, 50, 0);
PImage img; img = loadImage(“laDefense.jpg”); image(img, 0, 0); tint(255, 126); // Apply transparency without changing color image(img, 50, 0); |
||||||||||||
Description |
Sets the fill value for displaying images. Images can be tinted to specified colors or made transparent by including an alpha value. To apply transparency to an image without affecting its color, use white as the tint color and specify an alpha value. For instance, tint(255, 128) will make an image 50% transparent (assuming the default alpha range of 0-255, which can be changed with colorMode()). When using hexadecimal notation to specify a color, use “#” or “0x” before the values (e.g., #CCFFAA or 0xFFCCFFAA). The # syntax uses six digits to specify a color (just as colors are typically specified in HTML and CSS). When using the hexadecimal notation starting with “0x“, the hexadecimal value must be specified with eight characters; the first two characters define the alpha component, and the remainder define the red, green, and blue components. The value for the gray parameter must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255. The tint() function is also used to control the coloring of textures in 3D. 设置显示图像的填充值。图像可以着色为指定的颜色, 或通过包含 alpha 值使其透明。
若要对图像应用透明度而不影响其颜色, 请使用白色作为淡色颜色并指定 alpha 值。例如, 淡色 (255、128) 将使图像50% 透明 (假设默认的 alpha 范围为 0-255, 可以用 colorMode () 进行更改)。
使用十六进制表示法指定颜色时, 在值之前使用 “#” 或 “0x” (例如, CCFFAA 或 0xFFCCFFAA)。# 语法使用六位数字来指定颜色 (就像通常在 HTML 和 CSS 中指定颜色一样)。当使用以 “0x” 开头的十六进制符号时, 必须用八字符指定十六进制值。前两个字符定义了 alpha 分量, 其余部分定义了红色、绿色和蓝色分量。
灰色参数的值必须小于或等于 colorMode () 指定的当前最大值。默认最大值为255。
淡色 () 函数也用于在3D 中控制纹理的着色。 |
||||||||||||
Syntax |
tint(rgb) tint(rgb, alpha) tint(gray) tint(gray, alpha) tint(v1, v2, v3) tint(v1, v2, v3, alpha) |
||||||||||||
Parameters |
|
||||||||||||
Returns |
void |
||||||||||||
Related |
noTint() |
- 本文固定链接: http://iprocessing.cn/2017/08/09/tint设置图像填充色/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表