Gnuplot RGB-alpha 线型和大整数问题
Gnuplot RGB-alpha linestyles and large int problem
我正在尝试使用 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
returns 是一个负数,然后无法识别为颜色。有没有办法在 gnuplot 中获取 unsigned int?或者任何其他方式将数字理解为 #80000000 以外的十六进制?
使用运算符左移无符号<<
,勾选help operators binary
.
同时检查一下:
代码:
### 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
结果:
我正在尝试使用 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
returns 是一个负数,然后无法识别为颜色。有没有办法在 gnuplot 中获取 unsigned int?或者任何其他方式将数字理解为 #80000000 以外的十六进制?
使用运算符左移无符号<<
,勾选help operators binary
.
同时检查一下:
代码:
### 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
结果: