gpt4 book ai didi

Gnuplot RGB-alpha 线型和大整数问题

转载 作者:行者123 更新时间:2023-12-02 19:33:45 25 4
gpt4 key购买 nike

我正在尝试使用 gnuplot 创建透明颜色的自定义调色板:

a=127
rgb(i,a)=int(255*256**(i%3)+(i/3)*96*256**((i+1)%3)+a*256**3)

然后我确实获得了所需的颜色:

plot x w l lc rgb rgb(0,a) lw 32, x+1 w l lc rgb rgb(1,a) lw 32

问题,如果 a 等于或大于 128,int 返回一个负数,该负数不会被识别为颜色。有没有办法在 gnuplot 中获取 unsigned int ?或者有任何其他方法可以将数字理解为十六进制超过 #80000000 吗?

最佳答案

使用无符号左移运算符 << ,检查help operators binary .

另请检查:https://stackoverflow.com/a/60257784/7295599

代码:

### create your own transparent palette
reset session

# a,r,g,b should be integers between 0 and 255 (or 0x00 and 0xff)
a = 127 # transparency
r = 0xff # red
g = 0x00 # green
b = 0x00 # blue
myColor(a,r,g,b) = (a<<24) + (r<<16) + (g<<8) + b

# put some objects in the background to demonstrate transparency
set object 1 rect from -7,0 to -3,250 fs solid 1.0 fc rgb "green" behind
set object 2 rect from 3,0 to 7,250 fs solid 1.0 fc rgb "blue" behind

plot for [a=0:250:10] a w l lw 5 lc rgb myColor(a,r,g,b) notitle
### end of code

结果:

enter image description here

关于Gnuplot RGB-alpha 线型和大整数问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61403137/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com