HSB圆形调色板设计和计算方法
RGB调色板绘制较容易,HSB调色板较难绘制,前些天发文介绍了几个圆形样例的绘制方法,今介绍圆形的HSB调色板的设计方法和H,S,B值的计算方法,好东西必须与大家分享。
此文介绍HSB调色板和选色条的绘制方法,依据此方法可以仿制那些大牌绘图软件的调色板,在自己编制应用程序时遇到需要选色时,就要有调色板来选色,此方法就能使你很方便地创制自己的调色板。
图上的圆形调色板是H色板,选色在0°-360°,取得色相H值,计算取得RGB色值,再依Hue色相的值度数计算Saturation饱和度和Brightness亮度。这就是HSB色彩模式。网上有计算公式,我试了一下,感到很烦,不着边际。于是就设计了自己的计算方法。如何计算HSV,如何联动显示选色条和标示选色块,如何标示RGB和HSB的值,在代码中有注释说明。
H调色板选色,计算 Rad, ang, L, return H
计算二点距离 L,取色点到圆心距离
x0=250; y0=230; // H 调色板中心点
x1=px; y1=py; //mouse click new point px, py
L=(float)(sqrt ((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))) ;
计算取色点弧度rad, 转角度ang
Rad=(float)(atan2 ((y1-y0), (x1-x0) ) ) ; //弧度
ang=(int)(Rad*180/pi) ; //转角度
if (ang<0) ang=ang+360 ;
if (ang>360) ang=360-ang ;
H=(int)( ang ) ; //* return H=角度,L=长度
//****计算如此简单,没深奥的公式 *****
L值可用于圆盘上计算S,B值。本例不采用此法。
SB选色条有二类:
一是双条式:S条饱和度从左起为100,向右趋向于0,即从原色到白色。B条亮度从右起为100,向左趋向于0,即从原色到黑色。B条也可设置为左起。
二是单条式:SB条合二为一,中间是它们的起始值100。S饱和度从中间100向右趋向于0,即从原色到白色。B亮度从中间100向左趋向于0,即从原色到黑色。
本例采用单条式,本人倾向于单条式,简单易操作。
HSB圆形调色板设计要点:
1)界面设计,H 调色板绘制,SB 选色条绘制, colorpad9 () ;
2)H 调色板点击选色,Hselect (), H 值计算;
3)H 值更新,同步SB 选色条更新,HRenew ();
4)SB 选色条点击选色,SVRenew (),S, B值计算,值更新,显示更新。
源码中有详细注释,原理和语法都很简单,适用于初学者。希望大家喜欢。大家的点评是对我的鼓励。
补充一点,H板mouse或触控,若限定宽高,计算H是度数,不会有越界问题。 SB选色条也这样。
RGB色 (+-)可设置调节rgb色彩,本例未设置。
以下是源码:
//OK按钮设置,色框点击取色
//H色板mousemove, click选色 {
px=x; py=y; //设置为mousemove
Hselect () ; } //H 色板click选色
//SV选色mousemove, click选色 {
sx=x; sy=y; //设置为mousemove
SVRenew () ; } //SV选色条click选色
// 新的色框 click > 改变 > 当前颜色 {
cs.SetFillMode (1) ;
cs.SetColor (255, r1, g1, b1 ) ;
cs.DrawRect (470,167,550,204); } //当前色
//cmdOK_click ( ) {
// OK按钮, click 新的颜色选用 > 应用
cs.SetFillMode (1) ;
cs.SetColor (255, 250,250,250) ;
cs.DrawRect (50,630,170,670); //新的选色
cs.SetColor (255, r1, g1, b1) ;
cs.DrawRect (52,632,168,668); //新的选色
cs.SetTextSize (20);
cs.SetColor (255,0,250,0 ) ;
ss="应用颜色:";
cs.DrawText (ss, 50,610) ; }
//***************
SVRenew (){
//SV色板click 取得 xpos=sx,调节色彩
cs.SetFillMode (1) ;
cs.SetColor (255,100,100,100);
cs.DrawRect (35,150,98,175);
cs.SetTextSize (20);
cs.SetColor (255,0,250,0 ) ;
kn=(int)(sx) ;
ss=intToString (kn) ;
// cs.DrawText (ss, 40,167) ; //调试,可不显示
if (kn<295){
V=(int)((kn-40)/2.55) ; S=100 ;
kn=(int)((100-V)*2.55) ;
R= cr-kn ; if (R<0) R=0;
G=cg-kn ; if (G<0) G=0;
B=cb-kn ; if (B<0) B=0; }
if (kn>=295){
S=(int)((550-kn)/2.55) ; V=100 ;
kn=(int)((100-S)*2.55) ;
R= cr+kn ; if (R>255) R=255;
G= cg+kn ; if (G>255) G=255;
B= cb+kn ; if (B>255) B=255; }
r1=R; g1=G; b1=B;
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255, R, G, B ) ;
cs.DrawRect (470,102,550,139); //新的色
cs.SetTextStyle (0) ;
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,150,150,150);
cs.DrawRect (610,327,665,360); //擦除
cs.DrawRect (610,367,665,400);
cs.SetColor (255,250,250,250 ) ;
ss2=intToString (S); //更新SV值
ss3=intToString (V);
tab=0 ;
if (S<10) tab=12;
if (S>9&&S<100) tab=6 ;
cs.DrawText (ss2, 620+tab,350);
tab=0 ;
if (V<10) tab=12;
if (V>9&&V<100) tab=6 ;
cs.DrawText (ss3, 620+tab,390);
//更新游标尺
cs.SetStrokeWidth(1);
cs.SetColor (255,120,120,120);
cs.DrawRect (36,396,555,408); //擦除
cs.SetColor (255,250,0,0);
cs.DrawRect (sx-1,398,sx+1,407); //游标尺
cs.DrawCircle (sx,400,4); //游标尺
cs.Update ();
}//SVRenew ()
Hselect (){
//H调色板选色,计算 Rad, ang, L, return H
//计算二点距离 L,取色点到圆心距离
x0=250; y0=230; // H pie center
x1=px; y1=py; //mouse click new point px, py
L=(float)(sqrt ((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))) ;
//计算取色点弧度rad, 转角度ang
Rad=(float)(atan2 ((y1-y0), (x1-x0) ) ) ; //弧度
ang=(int)(Rad*180/pi) ; //转角度
if (ang<0) ang=ang+360 ;
if (ang>360) ang=360-ang ;
H=(int)( ang ) ; //* return H=角度,L=长度
//****计算如此简单,如上,没深奥的公式 *****
cs.SetFillMode (1);//0不填色,1填色
cs.SetTextSize (20);
cs.SetColor (255,100,100,100);
cs.DrawRect (35,105,98,150); //显示H选色
ss=intToString (H)+" ° " ;
cs.SetColor(255,0, 250, 0 );
cs.DrawText (ss, 40,125 ) ; //调试,可不显示
kn=(int)(L) ;
ss="L="+intToString (kn) ;
//cs.DrawText (ss, 40,145 ) ; //调试,可不显示
//标记H值画标记点,更新数值,更新选色块
cs.SetFillMode (0);//0不填色,1填色
cs.SetStrokeWidth(11);
cs.SetColor(255,110,110,110 );
cs.DrawCircle (x0,y0,157) ; //消除原点
cs.SetFillMode (1);//0不填色,1填色
a=pi/180*H ; r=150 ;
x2=(float)((r+6)*cos (a))+x0 ;
y2=(float)((r+6)*sin (a))+y0 ;
cs.SetColor(255,255,0,0 );
cs.DrawCircle (x2,y2,5) ; //画新点
cs.Update ();
//更新数值计算,更新显示
HRenew () ;
}//Hselect ()
HRenew (){ //依H值更新
//**** 计算HSV ********
//调色板尺寸: 圆盘 r=150, 圆心 x=250, y=230
//mouse 调色板取色 xpos, ypos 计算 Hue 值
//计算也可加S饱和度设置,即二点距离 L长度
//可计算取得 RGB 值,cr, cg, cb
//六段画调色板 255/3=85, 85*6=510 = 色板宽度
// 1. (255,255,i,0); //red-yellow 0 - 59
// 2. (255,255-i,255,0); //yellow-green 60 -119
// 3. (255,0,255,i); //green-blue 120-179
// 4. (255,0,255-i,255); //blue-purple 180-239
// 5. (255, i , 0,255); //purple-magenta 240-299
// 6. (255,255,0,255-i); //magenta-red 300-360
//依此6段设色,每段60度,可定RGB色
//初始调用时 H=0 , 0度 , rgb=( 255, 0, 0 )
//* H色板显示mouse 选色,计算RGB (r,g,b)
cs.SetFillMode (1) ; //画鼠标已选色
if (H<=60) { //1. red
cr=255; cb=0;
cg=(int)(H*255/60) ; }
if (H>60&&H<=120) { //2. yellow
cg=255; cb=0;
cr=(int)(255-(H-60)*255/60) ; }
if (H>120&&H<=180) { //3. green
cr=0; cg=255;
cb=(int)((H-120)*255/60) ; }
if (H>180&&H<=240) { //4. cyan
cg=(int)(255-(H-180)*255/60 ) ;
cr=0 ; cb=255 ; }
if (H>240&&H<=300) { //5. blue
cr=(int)((H-240)*255/60 ) ;
cg=0 ; cb=255 ; }
if (H>300&&H<=360) { //6. magenta
cr=255; cg=0;
cb=(int)(255-(H-300)*255/60 ) ; }
//R=cr; G=cg; B=cb; // (+ - )click改变新的色
r1=cr ; g1=cg ; b1=cb ; //设置 原采色
//依选色值计算,显示取色
//选色显示:当前,新的, H 采色
cs.SetFillMode (1) ;
cs.SetColor (255,cr, cg, cb ); //依选色显示
cs.DrawRect (612,82,664,134); //H板色show
cs.DrawRect (470,102,550,139); //新的选色
//取色后,S和V 的初始值是100。即选色条的中心位
S=100 ; V=100 ; //H值更新后初始值
//px=295 ; //H色板取色后游标初始值100
//选色条颜色依所取色来绘出,六类基色1-6
//依据取色条的游标的xpos值计算 SV值
//中心点=295,
//依H值的rgb绘制SV选色条:draw S,B bar
cs.SetStrokeWidth(2);
for (i=0; i<=255; i++){ //调色板:选色条
R=cr+i ; G=cg+i ; B=cb+i ;
if (R>255) R=255 ;
if (G>255) G=255 ;
if (B>255) B=255 ;
cs.SetColor (255, R, G, B ) ; //S条
cs.DrawLine (295+i, 410,295+i ,440);
R=cr-i ; G=cg-i ; B=cb-i ;
if (R<0) R=0 ;
if (G<0) G=0 ;
if (B<0) B=0 ;
cs.SetColor (255, R, G, B ) ; //B条
cs.DrawLine (295-i ,410,295-i, 440 ); }
//画游标,选色后S, V值100=295 中间点位
cs.SetFillMode (1);//0不填色,1填色
// x1=295 > S, V值100=295 中间点位
if (S==100&&V==100) x1=295 ;
cs.SetStrokeWidth(2);
cs.SetColor (255,120,120,120);
cs.DrawRect (36,396,555,408); //擦除
cs.SetColor (255,250,0,0);
cs.DrawRect (x1-1,398,x1+1,407); //游标尺
cs.DrawCircle (x1,401,4); //游标尺
cs.SetTextStyle (0) ;
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,150,150,150);
cs.DrawRect (610,147,665,180); //标值
cs.DrawRect (610,187,665,220);
cs.DrawRect (610,227,665,260);
cs.DrawRect (610,287,665,320);
cs.DrawRect (610,327,665,360);
cs.DrawRect (610,367,665,400);
//更新值显示
cs.SetColor (255,250,250,250);
cs.SetTextSize (20);
ss1=intToString (cr);
ss2=intToString (cg);
ss3=intToString (cb);
tab=0 ; //put text center
if (cr<10) tab=12;
if (cr>9&&cr<100) tab=6 ;
cs.DrawText (ss1, 620+tab,170);
tab=0 ;
if (cg<10) tab=12;
if (cg>9&&cg<100) tab=6 ;
cs.DrawText (ss2, 620+tab,210);
tab=0 ;
if (cb<10) tab=12;
if (cb>9&&cb<100) tab=6 ;
cs.DrawText (ss3, 620+tab,250);
ss1=intToString (H);
ss2=intToString (S);
ss3=intToString (V);
tab=0 ;
if (H<10) tab=12;
if (H>9&&H<100) tab=6 ;
cs.DrawText (ss1, 620+tab,310);
tab=0 ;
if (S<10) tab=12;
if (S>9&&S<100) tab=6 ;
cs.DrawText (ss2, 620+tab,350);
tab=0 ;
if (V<10) tab=12;
if (V>9&&V<100) tab=6 ;
cs.DrawText (ss3, 620+tab,390);
cs.Update ();
}//HRenew()
colorpad9 (){
cs.ClearDraw (0,src);
addPicture (); //加底图
cs.SetColor (255, 220,220,220); //画框线
cs.SetFillMode (0) ;
cs.SetStrokeWidth(1);
cs.DrawRect (468,100,551,140); //新的选色
cs.DrawRect (468,165,551,205); //当前色
cs.DrawRect (610,80,665,135); //H选色
cs.DrawRect (38,408,552,441); //SB条框线
//绘制圆盘形调色板:HSB 拾色器选项卡画法
//*********全色谱真彩调色板(6)六分画法
cs.SetStrokeWidth(2); //线宽
dx=250 ; dy=230 ; r=150 ;
for (i= 0; i<=120 ; i++ ){ //red-orange
a=pi/360*i ;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
cr=250 ; cg=i*2-i/3 ; cb=0 ;
cs.SetColor(255,cr, cg, cb );
cs.DrawLine (dx,dy,x0,y0) ; }
for (i= 0; i<=120 ; i++ ){ //yellow-green
a=pi/360*(i+120) ;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
cr=250-i ; cg=210+i/3; cb=0 ;
cs.SetColor(255,cr, cg, cb );
cs.DrawLine (dx,dy,x0,y0) ; }
for (i= 0; i<=120 ; i++ ){ //green-blue
a=pi/360*(i+240) ;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
cr=130-i ; cg=250 ; cb=i*2 ;
cs.SetColor(255,cr, cg, cb );
cs.DrawLine (dx,dy,x0,y0) ; }
for (i= 0; i<=120 ; i++ ){ //blue-purple
a=pi/360*(i+360) ;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
cr=60-i/2 ; cg=240-i-i/2-i/3 ; cb=255 ;
cs.SetColor(255,cr, cg, cb );
cs.DrawLine (dx,dy,x0,y0) ; }
for (i= 0; i<=122 ; i++ ){ //purple-magenta
a=pi/360*(i+480) ;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
cr=i*2 ; cg=30-i/4; cb=255 ;
cs.SetColor(255,cr, cg, cb );
cs.DrawLine (dx,dy,x0,y0) ; }
for (i= 0; i<=120 ; i++ ){ //magenta-red
a=pi/360*(i+600) ;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
cr=250; cg=0 ; cb=230-i*2+10;
cs.SetColor(255,cr, cg, cb );
cs.DrawLine (dx,dy,x0,y0) ; }
cs.SetStrokeWidth(1); //线 , print " 120° "
cs.SetFillMode (1) ;
cs.SetTextSize (16);
for (n=0; n<=5; n++){ //六分线
a=pi/180*n*60; r=165;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
x1=(float)((r-30)*cos (a))+dx ;
y1=(float)((r-30)*sin (a))+dy ;
cs.SetColor(255, 250, 250, 250 );
cs.DrawLine (x1,y1, x0,y0) ;
x2=(float)((r+20)*cos (a))+dx ;
y2=(float)((r+10)*sin (a))+dy ;
kn=n*60 ;
ss=intToString (kn)+"° " ;
cs.SetColor(255,250, 250, 250 );
cs.DrawText (ss, x2-15,y2+5) ; }
// HSB 模式:(HSV同,V=Value)
// Hues 色相, Saturation 饱和度, Brightness 亮度
//画中心高光 brightness
cs.SetFillMode (0) ;
cs.SetStrokeWidth(1); //线宽
for (i= 0; i<=360 ; i++ ){
a=pi/360*i*2 ; r=100 ;
x0=(float)(r*cos (a))+dx ;
y0=(float)(r*sin (a))+dy ;
cs.SetColor(10,255,255,255 );
cs.DrawLine (dx,dy,x0,y0) ; }
cs.SetStrokeWidth(2); //线宽
for (i= 0; i<=90 ; i++ ){ //0-110
cs.SetColor(180-i*2,255,255,255 );
cs.DrawCircle (dx,dy,i) ; }
//**** 计算HSV ********
//调色板尺寸: px=250, py=230, r=150
//点击计算H度数,可取得 RGB 值,cr, cg, cb
//六段画调色板,圆色板H角度,方色板宽度360分
// 1. (255,255,i,0); //red-yellow 0 - 59
// 2. (255,255-i,255,0); //yellow-green 60 -119
// 3. (255,0,255,i); //green-blue 120-179
// 4. (255,0,255-i,255); //blue-purple 180-239
// 5. (255, i , 0,255); //purple-magenta 240-299
// 6. (255,255,0,255-i); //magenta-red 300-360
//依此6段设色,每段60度,可定RGB色
//标记H值画标记点,更新数值,更新选色块
x0=250; y0=230;
cs.SetFillMode (0);//0不填色,1填色
cs.SetStrokeWidth(11);
cs.SetColor(255,110,110,110 );
cs.DrawCircle (x0,y0,157) ; //消除原点
cs.SetFillMode (1);//0不填色,1填色
a=pi/180*H ; r=150 ;
x2=(float)((r+6)*cos (a))+x0 ;
y2=(float)((r+6)*sin (a))+y0 ;
cs.SetColor(255,255,0,0 );
cs.DrawCircle (x2,y2,5) ; //画新点
cs.Update ();
//H色板显示mouse 选色,计算RGB (r,g,b)
cs.SetFillMode (1) ; //画鼠标已选色
if (H<=60) { //1. red
cr=255; cb=0;
cg=(int)(H*255/60) ; }
if (H>60&&H<=120) { //2. yellow
cg=255; cb=0;
cr=(int)(255-(H-60)*255/60) ; }
if (H>120&&H<=180) { //3. green
cr=0; cg=255;
cb=(int)((H-120)*255/60) ; }
if (H>180&&H<=240) { //4. cyan
cg=(int)(255-(H-180)*255/60 ) ;
cr=0 ; cb=255 ; }
if (H>240&&H<=300) { //5. blue
cr=(int)((H-240)*255/60 ) ;
cg=0 ; cb=255 ; }
if (H>300&&H<=360) { //6. magenta
cr=255; cg=0;
cb=(int)(255-(H-300)*255/60 ) ; }
// cs.SetColor (255,cr, cg, cb ); //依选色显示
r1=cr ; g1=cg ; b1=cb ; //保留原色
R=cr ; G=cg ; B=cb ; //保留原色
//依选色值计算,显示取色
//选色显示:当前,新的
cs.SetFillMode (1) ;
cs.SetColor (255,cr, cg, cb ); //依选色显示
cs.DrawRect (612,82,663,133); //已选色show
cs.DrawRect (470,102,550,139); //新的选色
// cs.DrawRect (470,167,550,204); //当前色
//画标尺标线
cs.SetStrokeWidth(1);
cs.SetTextSize (22);
for (i=0; i<=20; i++){
dx=i*10*51/20 ;
cs.SetColor (255, 250, 250, 250 ) ;
cs.DrawLine (dx+39,444,dx+39,449); }
cs.SetFillMode (1) ;
cs.SetTextSize (16);
cs.DrawText ("0 ", 34,462);
cs.DrawText ("0 ", 544,462);
cs.DrawText ("< B 100 S > ", 242, 462);
//取色后,S和V 的初始值是100。即选色条的中心位
S=100 ; V=100 ; //初始值
//H色板取色后游标初始值100
//此色依H色板值计算 > 画选色条
//六类基色1-6
//依据取色条的游标的xpos值计算 SV值
//中心点=(S+V)/2+40=(255+255)/2+40=295,
//依H值的rgb绘制SV选色条:draw S,V bar
cs.SetStrokeWidth(2);
for (i=0; i<=255; i++){ //调色板:选色条
R=cr+i ; G=cg+i ; B=cb+i ;
if (R>255) R=255 ;
if (G>255) G=255 ;
if (B>255) B=255 ;
cs.SetColor (255, R, G, B ) ;
cs.DrawLine (295+i, 410,295+i ,440);
R=cr-i ; G=cg-i ; B=cb-i ;
if (R<0) R=0 ;
if (G<0) G=0 ;
if (B<0) B=0 ;
cs.SetColor (255, R, G, B ) ;
cs.DrawLine (295-i ,410,295-i, 440 ); }
//画SV选色条游标尺
//sx=295 > S, V值=100> 295 中间点位
sx=295 ; //初始值
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(1);
cs.SetColor (255,120,120,120);
cs.DrawRect (36,396,555,408); //擦除
cs.SetColor (255,250,0,0);
cs.DrawRect (sx-1,398,sx+1,407); //游标尺
cs.DrawCircle (sx,400,4); //游标尺
cs.SetTextStyle (0) ;
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,150,150,150);
cs.DrawRect (610,147,665,180); //标值
cs.DrawRect (610,187,665,220);
cs.DrawRect (610,227,665,260);
cs.DrawRect (610,287,665,320);
cs.DrawRect (610,327,665,360);
cs.DrawRect (610,367,665,400);
cs.SetTextSize (20);
cs.SetColor (255,240,240,240);
cs.DrawText ("H : ", 580,115);
cs.DrawText ("R : ", 580,170);
cs.DrawText ("G : ", 580,210);
cs.DrawText ("B : ", 580,250);
ss1=intToString (cr);
ss2=intToString (cg);
ss3=intToString (cb);
tab=0 ; //put text center
if (cr<10) tab=12;
if (cr>9&&cr<100) tab=6 ;
cs.DrawText (ss1, 620+tab,170);
tab=0 ;
if (cg<10) tab=12;
if (cg>9&&cg<100) tab=6 ;
cs.DrawText (ss2, 620+tab,210);
tab=0 ;
if (cb<10) tab=12;
if (cb>9&&cb<100) tab=6 ;
cs.DrawText (ss3, 620+tab,250);
cs.DrawText ("H : 度", 580,310);
cs.DrawText ("S : % ", 580,350);
cs.DrawText ("B : % ", 580,390);
ss1=intToString (H);
ss2=intToString (S);
ss3=intToString (V);
tab=0 ;
if (H<10) tab=12;
if (H>9&&H<100) tab=6 ;
cs.DrawText (ss1, 620+tab,310);
tab=0 ;
if (S<10) tab=12;
if (S>9&&S<100) tab=6 ;
cs.DrawText (ss2, 620+tab,350);
tab=0 ;
if (V<10) tab=12;
if (V>9&&V<100) tab=6 ;
cs.DrawText (ss3, 620+tab,390);
cs.DrawText ("新的 ", 490,160);
cs.DrawText ("当前 ", 490,225);
//画按钮
cs.SetColor (255,120,120,120);
cs.DrawRect (570,460,664,499); //按钮
cs.DrawRect (430,460,524,499); //按钮
cs.SetColor (255,250,250,250);
cs.DrawRect (572,461,662,496); //按钮
cs.DrawRect (432,461,522,496); //按钮
cs.SetColor (255,200,200,200);
cs.DrawRect (574,464,662,497); //按钮
cs.DrawRect (434,464,522,497); //按钮
cs.SetColor (255,220,220,220);
cs.DrawRect (575,464,658,493); //按钮
cs.DrawRect (435,464,518,493); //按钮
cs.SetColor (255,0,0,0);
cs.SetTextSize (22);
cs.DrawText ("确 定 ", 595, 487);
cs.DrawText ("取 消 ", 455, 487);
//另外RGB选色可加调整小按钮+-选色
//也可使用scrollbar来设置,调节RGB色,
// S 选色条和 B 选色条联动显示选色
cs.SetColor (255,250,0,0); //调色按钮red
cs.DrawRect (667,147,690,163);
cs.DrawRect (667,164,690,180);
cs.SetColor (255,0,240,0); //调色按钮green
cs.DrawRect (667,187,690,203);
cs.DrawRect (667,204,690,220);
cs.SetColor (255,0,0,250); //调色按钮blue
cs.DrawRect (667,227,690,243);
cs.DrawRect (667,244,690,260);
cs.SetColor (255,250,250,250); //调色按钮
cs.DrawText ("+ ",672,162);
cs.DrawText ("-- ",672,178);
cs.DrawText ("+ ",672,202);
cs.DrawText ("-- ",672,218);
cs.DrawText ("+ ",672,242);
cs.DrawText ("-- ",672,258);
//print 题标
cs.SetTextSize (32);
cs.SetStrokeWidth(1); //线宽
cs.SetTextStyle (1) ;
cs.SetFillMode (1) ;
ss="HSB 圆形调色板设计 示例 9 " ;
cs.SetColor (255,0,50,0);
cs.DrawText (ss,184,579);
cs.DrawText ("HSB ", 40,100);
cs.SetColor (255,0,250,0);
cs.DrawText (ss,180,575);
cs.DrawText ("HSB ", 40,100);
cs.SetFillMode (0) ;
cs.SetColor (255,255,180,0);
cs.DrawText (ss,180,575);
cs.DrawText ("HSB ", 40,100);
cs.Update ();
}// colorpad9 ()
addPicture (){ //加底图
fname="/storage/emulated/0/form.jpg";
cs.DrawBitmap(fname,0,6); //加底图
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,0,0,0);
cs.DrawRect (0,2,720,22);
cs.DrawRect (0,2,12,570);
cs.DrawRect (0,570,720,800);
cs.SetColor (255,100,100,100);
cs.DrawRect (28,65,709,521); //大框线
cs.Update ();
}//addPicture()
//**** End ********