如何在不触摸颜色本身的情况下解决颜色透明度/不透明度? V5

发布于 2025-01-29 05:21:48 字数 262 浏览 2 评论 0原文

例如,我有这些颜色变量:

Color1 = #334455FF
Color2 = #33445588

唯一的区别是不透明度/透明度组件。我们只能在不触摸RGB Comps的情况下仅解决此组件吗?例如(即兴明显的语法概念):

Color1 = #334455FF
Color2 = @Color1, opacity=50

我认为V4中有一些相似的功能……(我只是在那个时代不在这里。)

For example I have these color variables:

Color1 = #334455FF
Color2 = #33445588

The only difference is the opacity/transparency component. Can we address this component only, without touching the RGB comps.? For example (improvised obvious syntax concept):

Color1 = #334455FF
Color2 = @Color1, opacity=50

I think there was some similar function in V4 … (I just wasn't here in that era.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨巷深深 2025-02-05 05:21:48
transp = input.int(0, minval=0,maxval=100)
colbase = input.color(color.yellow)

var color _col = na 

_col := color.new(colbase, transp)

plot(close,'close',_col,3)
transp = input.int(0, minval=0,maxval=100)
colbase = input.color(color.yellow)

var color _col = na 

_col := color.new(colbase, transp)

plot(close,'close',_col,3)
心病无药医 2025-02-05 05:21:48

我相信您正在寻找color.t()函数。

检索颜色的透明度。

//@version=5
indicator("color.t", overlay=true)
plot(color.t(color.new(color.red, 50)))

编辑:

您可以使用color.r()color.g()color.b()函数以获取R, g,b颜色的成分。然后使用color.rgb()函数来创建新颜色。

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius

//@version=5
indicator("My script")

color1 = color.new(#c9ff73, 0)

color_r = color.r(color1)
color_g = color.g(color1)
color_b = color.b(color1)

color2 = color.rgb(color_r, color_g, color_b, 25)
color3 = color.rgb(color_r, color_g, color_b, 50)
color4 = color.rgb(color_r, color_g, color_b, 75)

plot(0, "1", color1, linewidth=5)
plot(5, "2", color2, linewidth=5)
plot(10, "3", color3, linewidth=5)
plot(15, "4", color4, linewidth=5)

I believe you are looking for the color.t() function.

Retrieves the color's transparency.

//@version=5
indicator("color.t", overlay=true)
plot(color.t(color.new(color.red, 50)))

Edit:

You can use the color.r(), color.g(), color.b() functions to get the r, g, b components of a color. Then use the color.rgb() function to create a new color.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius

//@version=5
indicator("My script")

color1 = color.new(#c9ff73, 0)

color_r = color.r(color1)
color_g = color.g(color1)
color_b = color.b(color1)

color2 = color.rgb(color_r, color_g, color_b, 25)
color3 = color.rgb(color_r, color_g, color_b, 50)
color4 = color.rgb(color_r, color_g, color_b, 75)

plot(0, "1", color1, linewidth=5)
plot(5, "2", color2, linewidth=5)
plot(10, "3", color3, linewidth=5)
plot(15, "4", color4, linewidth=5)

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文