C语言绘图示例-分色调图20例

C语言绘图示例-分色调图20例

PhotoShop,AutoCad,3DS,Paint等图形图像绘画应用软件都有真彩调色板,也有各种分色调的调色板选项卡,供使用者画笔取色用。16m色也就是俗称真彩的全部色彩。

本人编制的商标徽标制作软件、画板绘画软件、创意艺术字制作软件也制作此真彩调色板。需要的同好可参考我在本站上传的资源。

本文介绍真彩调色板绘制方法,另外添加了各种分色调调色板的绘制方法。今分享给大家,希望大家喜欢。

255色阶分Step4,Step2绘出,是为提高调色板绘出的显示速度,此色度肉眼分辨不出。255色阶逐步绘制是全色调模式,绘制速度慢,可在程序启动时先行绘出。此色板渐变色可用于制作创意艺术字的多彩渐变色字,也可用于页面图片底图底色背景色彩。

我空余时在安卓手机上用myspringc语言编写的绘图示例,各种绘图方法可供喜欢的朋友参考。

MySpringC不仅可以编写简单的C语言程序,而且它能读取手机中各种传感器的数值,控制各种多媒体设备,从而实现让普通用户用C语言控制手机,编写出意想不到的、适合自己使用的应用。

以下是源码和图例:
//  最简单的 C 语言编程
//  myspringc  v2 .7  可编译安卓本机 app 应用
//  此样例可复制黏贴到 myspringc  编译
//  此文档可用 VB,VC  ,  java 改写
//***************************************
//****   C语言绘图示例-调色板  *******
//***************************************
Canvas cs ;     //画布
string sBarDes[10];
int nBarId[10];
string sMenu[50];
int nMenu[50];
float src[4];  //ClearDraw (cls) clear screen
string s,ss,ss1,ss2,ss3;
int sx,sy,dx,dy;
 int size[2];
int i,j,n,t,k;    //t=times,n=number
int sn;    //mode number
 int r1,g1,b1;     //16m 全色调色板
double dn;

main(){
setDisplay(1);
  cs.SetBackground(150,150,150);
  cs.Active();

   sBarDes[0]="演  示";
   nBarId[0]=100;
   sBarDes[1]="上一例 ";
   nBarId[1]=101;
   sBarDes[2]="下一例 ";
   nBarId[2]=102;
   sBarDes[3]="  ";
   nBarId[3]=103;
   sBarDes[4]="退出程序";
   nBarId[4]=104;
   sBarDes[5]=" ";
   nBarId[5]=105;
   setToolBarHeight(6);
   setButtonTextSize(14);
   setToolBarBackgroundColor(255,192,192,192);
   setButtonColor(255,0,0,240);
   setButtonTextColor(255,255,255,0);
   setToolBar(100,myToolBarProc,sBarDes,nBarId,6);

  setTitle("调色板设计   ");
  sn=1;     show_pad();     //程序启动时绘出
while (){}
  }//main ()

show_pad (){ //演示例序
  if (sn==1) colorpad1 ();
  if (sn==2) colorpad2 ();
  if (sn==3) pad3 ();
  if (sn==4) pad4 ();
  if (sn==5) pad5 ();
  if (sn==6) pad6 ();
  if (sn==7) pad7 ();
  if (sn==8) pad8 ();
  if (sn==9) pad9 ();
  if (sn==10) pad10 ();
  if (sn==11) pad11 ();
  if (sn==12) pad12 ();
  if (sn==13) pad13 ();
  if (sn==14) pad14 ();
  if (sn==15) pad15 ();
  if (sn==16) pad16 ();
  if (sn==17) pad17 ();
  if (sn==18) pad18 ();
  if (sn==19) pad19 ();
  if (sn==20) pad20 ();

}//show_pad ()

// dx = ( 0 To 255 ), dy = ( 0 To 128 )
//以适应 RGB 颜色值
//若dx=0 to 128,需调整 dx*2 , 或 sx*2

bac8e1f8b5dc4e02bffb093473f72b05.png

 

pad20(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (20) c25 ****
     //c25:  RGB(255 - dy, dx, dy)
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=250-sx;
          g1=sx*2 ;    b1=sy;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();

}//pad20() 

 

 

0026ee0d75f94063b8c14959a50ed3d7.png

 

pad19(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (19) c26 ****
    //c26:   RGB(255 - dy, 255 - dy, dx / 2)
     cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=255-sy*2;
          g1=255-sy ;    b1=sx*2 ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad19()

6856430b599a44e1963f5785fd1a63f4.png

 

pad18(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (18) c27 ****
    //c27:   RGB(255 - dy, dy * 2, dx / 2)
     cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=255-sy ;
          g1=sy*2 ;    b1=sx*2 ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad18()

e4436bea7fa24acbab1d46239a8a6eda.png

 

pad17(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (17) c28 ****
     //c28:   RGB(dx / 2, dy * 2, 255 - dy)
     cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=sx*2 ;
          g1=sy*2 ;    b1=255-sy ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad17()

396f8010f6754d19b7fde4820a762e17.png

 

pad16(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (16) c29 ****
    //c29:   RGB(255 - dy, 255 - dx / 2, dy + 128)
     cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=255-sy*2;
          g1=255-sx ;    b1=sy+128 ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad16()

67ba63387baf49d3bc86b3cd62170d5b.png

 

pad15(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (15) c30 ****
    //c30:   RGB(255 - dy, dx / 2, dy)
     cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=255-sy*2;
          g1=sx ;    b1=sy*2 ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad15()

59a0acfc62dd4b4ba7e280318d3635c9.png

 

pad14(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (14) c31 ****
    //c31:   RGB(255 - dy * 2, dx , dy )
     cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=255-sy*2;
          g1=sx*2 ;    b1=sy*2 ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad14()

6eb0cb07fbf042c9bcc5ddd5b8070948.png

 

pad13(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (13) c32 ****
    //c32:   RGB(255 - dy, 255 - dx, dy)
     cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=255-sy*2;
          g1=255-sx*2;    b1=sy;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad13()

605feed4e8994158ab28fe7a499c23fa.png

 

pad12(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (12) c33 ****
   //c33:   RGB(255 - dx, 255 -  dy, dy)
       cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
    for (sy=0;sy<128;sy++){  
          r1=255-sx*2;
          g1=255-sy*2;    b1=sy*2;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (255,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad12()

0add4e9d3af1462394064f932805cd12.png

 

pad11(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (11) c34 ****
    //c34:   RGB(dx, 128 - dy, 255 - dy * 2)
       cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
           r1=sx*2;
    for (sy=0;sy<128;sy++){  
           g1=128-sy ;    b1=255-sy*2 ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (155,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
             //cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad11()

dc02e3c087ba489786cbccf517133814.png

 

pad10(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (10) c35 ****
    //c35:   RGB(dx, 255 - dy * 2, 255 - dy * 2)
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
           r1=sx*2;
    for (sy=0;sy<128;sy++){  
           g1=255-sy*2 ;    b1=255-sy*2 ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (155,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
             //cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad10()

61cc3086318b498fb1e6a986a776945a.png 

 

pad9(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,200,200,200);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (9) c36 ****
   //c36:    RGB(dx, 128 - dy, 200 - dy)
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
           r1=sx*2;
    for (sy=0;sy<128;sy++){  
           g1=128-sy ;    b1=200-sy ;
          //RGB (a,r,g,b) , a 设置 0-255 > 透明到不透明
       cs.SetColor (55,r1,g1,b1);  
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
             //cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad9()

d6f3fc5657dd4c30bcc669a1078bfd5c.png

 

pad8(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,100,100,100);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (8) c37 ****
//c37:   RGB(255 - dy, 255 - dx / 2, 255 - dy)
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
           g1=255-sx*2;
    for (sy=0;sy<128;sy++){  
           r1=255-sy*2 ;    b1=255-sy*2 ;
       cs.SetColor (255,r1,g1,b1);
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
             //cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad8()

7534ffa416ba4b839d947160f0697f6f.png

 

pad7(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,100,100,100);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (7) c38 ****
 //c38:    RGB(255 - dy, 255 - dx, 255 - dy)
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色调色板
           g1=255-sx*2;
    for (sy=0;sy<128;sy++){  
           r1=128-sy ;    b1=255-sy*2 ;
       cs.SetColor (255,r1,g1,b1);
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad7()

6ea48e105fdd4a31bb8b77d99a7a19e2.png

 

pad6(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,100,100,100);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (6) c39 ****
     //== c39:   RGB(128 - dy, 255 - dx, 255 - dy)
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色 (6) 调色板
           g1=255-sx*2;
    for (sy=0;sy<128;sy++){  
           r1=128-sy ;    b1=sy*2 ;
       cs.SetColor (255,r1,g1,b1);
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad6()

5270ca6cf55c4689b2f828b440489179.png

 

pad5(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,100,100,100);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (5) c40 ****
   //c40:  ( R1=255 - dx: G1=255 - dx: B1=dy * 2)
       cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色 (5) 调色板
          r1=255-sx*2 ;   g1=255-sx*2;
    for (sy=0;sy<128;sy++){  
           b1=sy*2 ;
       cs.SetColor (255,r1,g1,b1);
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
            // cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad5()

d578edef60a943fb940de674adc24172.png

 

pad4(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,100,100,100);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 渐变色示例 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
  cs.DrawText ("正在绘制渐变色调色板 ...." ,150,250);
      cs.Update ();
   for (sx=0;sx<128;sx++){  //渐变色 (4) 调色板
          g1=sx*2;
    for (sy=0;sy<128;sy++){  
           r1=255-sy*2;   b1=sy*2 ;
       cs.SetColor (255,r1,g1,b1);
    cs.DrawRect (sx*4+50,sy*2+50,sx*4+54,sy*2+54);
               //cs.Update ();     //显示绘出过程
            }      }
      cs.Update ();
}//pad4()

 

96b315ee53b242ca83e2641dd7172b43.png

 

pad3(){
       cs.SetFillMode (1);//0不填色,1填色
           cs.SetStrokeWidth(2);
        cs.SetColor (255,250,250,250);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (1) ****
        cs.SetColor (255,20,20,140);
        cs.DrawText (" 调色板示例 ",20,35);
        s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
        cs.Update ();
     for (i=0;i<256;i++){  //色彩带 (1) 调色板
          cs.SetColor (255,255,i,0);
          cs.DrawLine (i*2+50,80,i*2+50,250);
            //  cs.Update ();     //显示绘出过程
            }
               cs.Update () ;
     for (i=0;i<256;i++){  //色彩带 (2) 调色板
         //color (a,  , ,) a=0 -- 255 。150 半透明
          cs.SetColor (150,255-i,i,120);
          cs.DrawLine (i*2+50,300,i*2+50,470);
   
         cs.SetColor (255,250,250,250);
         cs.DrawRect (490,260,560,300) ;
            n=(int)(i /255*100) ;
            ss=intToString (n);
         cs.SetColor (255,250,20,20);
          cs.DrawText (ss,500,290);
             cs.Update ();     //显示绘出过程
             }
    cs.SetColor (255,240,120,80);
    cs.SetTextSize (40);    
    cs.DrawText (" 双色渐变背景色板示例",110,530);
     cs.Update ();
}//pad3 ()

 

136be2ab50a7429d951cfe6e651779d4.png

 

colorpad1 (){
     cs.SetFillMode (1);//0不填色,1填色
        cs.SetColor (255,0,0,0);
        cs.DrawRect (0,4,720,600);
        cs.SetTextSize (30);    //*** (1) ****
        cs.SetColor (255,240,240,0);
        cs.DrawText (" 真彩调色板 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
        cs.Update ();
     r1= 0; g1= 255; b1= 255;   //blue
      for (i=0;i<32;i++){     // blue ********
             r1=i*8;       sx=i*6;
     for (j=0;j<32;j++){     
             g1=255-j*8;   sy=j*8;
             cs.SetColor (255,r1,g1,b1);
       cs.DrawRect (sx+50,sy+90,sx+58,sy+98); 
            //  cs.Update ();     //显示绘出过程
                }   }
      r1= 255; g1= 255; b1= 255;    //green
       for (i=32;i<64;i++){    // green ********
            r1=511- i*8 +255;   b1=511- i*8; sx=i*6;
       for (j=0;j<32;j++){     
            g1= 255 - j*8;   sy=j*8 ;
            cs.SetColor (255,r1,g1,b1);
       cs.DrawRect (sx+50,sy+90,sx+58,sy+98); 
               cs.Update ();     //显示绘出过程
                  }  }
        r1 = 0; g1 = 255; b1 = 0;    //red
      for (i=64;i<96;i++){    // red ********
              r1= i*8-511+255;  sx=i*6 ;
      for (j=0;j<32;j++){
             g1=255 -j*8;   sy=j*8 ;
             cs.SetColor (255,r1,g1,b1);
       cs.DrawRect (sx+50,sy+90,sx+58,sy+98); 
             //  cs.Update ();     //显示绘出过程
                }    }
    cs.SetColor (255,240,200,100);
    cs.SetTextSize (40);    
    cs.DrawText (" 16m色  真彩调色板 示例",110,400);
        cs.Update ();
}//colorpad1 ()

 

09fdac52b8c8451d8de8ef446cc5c201.png

 

colorpad2 (){
    cs.SetFillMode (1);//0不填色,1填色
        cs.SetColor (255,0,0,0);
        cs.DrawRect (0,4,720,600);
        cs.SetColor (255,200,250,0);
        cs.SetTextSize (30);    //*** (2) ****
        cs.DrawText (" 七色彩带调色板 ",20,35);
         s=intToString (sn);
        ss="mode = "+s ;
        cs.DrawText (ss,550,35);
        cs.Update ();
     for (i=0;i<256;i++){  //七色彩带 (2) 调色板
            cs.SetColor (255,255,i,0);
                cs.DrawLine (i/2+50,350,i/2+50,550);
                cs.DrawLine (600,i/2+40,680,i/2+40);
           cs.SetColor (255,255-i,255,0);
                cs.DrawLine (i/2+178,350,i/2+178,550);
                cs.DrawLine (600,i/2+168,680,i/2+168);
          cs.SetColor (255,0,255-i/2,i);
                cs.DrawLine (i/2+306,350,i/2+306,550);
                cs.DrawLine (600,i/2+296,680,i/2+296);
             //  cs.Update ();     //显示绘出过程
                     }
     for (i=0;i<256;i++){  //七色彩带 调色板
           cs.SetColor (255,i/2,128-i/2,255);
                cs.DrawLine (i/2+434,350,i/2+434,550);
                cs.DrawLine (600,i/2+424,680,i/2+424);
              cs.Update ();     //显示绘出过程
                    }
     cs.SetFillMode (0);//0不填色,1填色
           cs.SetColor (255,255,255,255);
     cs.DrawRect (50,50,560,300);
     cs.DrawRect (50,350,560,550);
        cs.SetColor (255,240,200,100);
        cs.SetTextSize (40);    
        cs.DrawText (" 七色彩带调色板 示例",110,190);

 

            cs.Update ();
}//colorpad2 ()

myToolBarProc(int nBtn,int nContext){
      if(nBtn==100){//演示
          cs.SetBackground(245,245,245);
          setDisplay (1);
          show_pad ();
                       }  
      if(nBtn==101){//mode+
            sn=sn-1;
            if (sn<1)sn=1;
            show_pad ();
            }
      if(nBtn==102){//mode -
            sn=sn+1;
            if (sn>20)sn=20;
            show_pad ();
             }
      if(nBtn==103){//显示图板
           setDisplay (1);
         }

      if(nBtn==104){//退出程序
         clearOutput();
         cs.ClearDraw (0,src);
         setDisplay (0);
          exit (0);
         }
     if(nBtn==105){// 
          setDisplay (1);
          //cover ();   
          }
}//myToolBar ()

 

//== End ==

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值