C语言绘画示例-进度条
C语言绘图示例-进度条
各种应用程序、应用软件启动时都有装载进度显示的进度条。媒体播放器也有提示播放进度的进度条。还有打开网页时有名的”转呀转呀”的进度显示环形图。
本人喜欢自制进度条,体验绘画的乐趣,感到很有成就感。试制了几款进度条,今将绘图方法分享给大家,希望大家喜欢。
我空余时在安卓手机上用myspringc语言编写的C语言绘图示例,可供喜欢的朋友参考。我编制的这个进度条示例程序最大的优点是可以演示动态显示进度条过程,颇具观赏性。
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 fname; //filename,load picture
string s,ss,ss1,ss2,ss3;
int sx,sy,dx,dy;
int size[2];
int i,j,d;
int n,t,k; //t=times,n=number
int sn; //mode number
int r1,g1,b1; //16m 全色调色板
float x0,y0,x1,y1;
float px,py,sx1,sy1,sx2,sy2;
float pi=3.1415926535;
double L,a;
int sec,min;
string s$,m$;
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("C语言绘图示例 ");
sn=17; show_pad(); //程序启动时即时绘出
while (){}
}//main ()
show_pad (){ //演示例序
if (sn==1) bar1 ();
if (sn==2) bar2 ();
if (sn==3) bar3 ();
if (sn==4) bar4 ();
if (sn==5) bar5 ();
if (sn==6) bar6 ();
if (sn==7) bar7 ();
if (sn==8) bar8 ();
if (sn==9) bar9 ();
if (sn==10) bar10 ();
if (sn==11) bar11 ();
if (sn==12) bar12 ();
if (sn==13) bar13 ();
if (sn==14) bar14 ();
if (sn==15) bar15 ();
if (sn==16) bar16 ();
if (sn==17) bar17 ();
if (sn==18) bar18 ();
}//show_pad ()
bar18(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,150,150,150);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,250,250,0);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,220,220,220);
cs.DrawCircle (i*2+113,385,20); }
for (i=0;i<201;i++){ //彩色底色
cs.SetColor (255,255-i/2,i+50,120);
cs.DrawCircle (i*2+113,385,18); }
cs.Update ();
for (i=0;i<101;i++){ //进度条 (18)
cs.SetColor (255,240,240,240); //mask
cs.DrawCircle (i*4+111,385,12);
for (d=0;d<12;d++){ //变色珠
cs.SetColor (255,255-d*6,150-d*6,0);
cs.DrawCircle (i*4+115,385,12-d); }
if ((i-i/3*3)==0&&i>3) {
for (j=0;j<5;j++){ //draw bar
cs.SetColor (255,255-i*2,i*2+50,120);
cs.DrawLine(i*4+95+j,377,i*4+90+j,393); } }
cs.SetColor (255,150,150,150); //clear
cs.DrawRect(537,367,620,403) ;
n=(int)(i ) ;
if(n<100) {k=15; }else{k=0 ; }
ss=intToString (n)+" %" ;
cs.SetColor (255,250,250,0);
cs.SetTextSize (26);
cs.DrawText (ss,540+k,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,150,150,150); //clear text
cs.DrawRect (100,300,320,358) ;
cs.SetColor (255,250,250,80);
cs.SetTextSize (40);
cs.DrawText (" 双色渐变进度条示例",110,530);
cs.Update ();
}//bar18()
bar17(){
cs.SetFillMode (1);//0不填色,1填色
fname="/storage/emulated/0/m01.jpg";
cs.DrawBitmap(fname,0,2); //加底图
cs.SetColor (255,120,30,0); //底色
cs.DrawRect (0,330,720,420);
cs.SetStrokeWidth(1);
cs.SetTextSize (26);
cs.SetColor (255,250,250,0);
//cs.DrawText (" 绘制进度条示例 ",20,35);
cs.DrawText ("音乐播放器> 北国之春 ",400,320);
cs.DrawText ("演唱:千昌夫 ",400,345);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,55);
cs.DrawText ("Play......" ,120,360);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,20,20,20);
cs.DrawCircle (i*2+113,385,3); }
cs.Update ();
for (i=0;i<101;i++){ //进度条 (17)
cs.SetColor (255,120,30,0); //mask
cs.DrawRect (100,373,i*4+115,380);
cs.DrawRect (100,390,i*4+115,397 );
cs.SetColor(225,i*2+55,i+50,250); // bar
cs.DrawCircle (i*4+117,385,9);
cs.SetColor (255,20,20,20);
cs.DrawCircle (i*4+117,385,5);
sleep (5);
cs.SetColor (255,120,30,0); //clear
cs.DrawRect(537,367,620,403) ;
cs.DrawRect(30,367,99,403) ;
sec=(i*2)/60 ; //show times
min=(i*2)-sec*60;
s$=intToString (sec);
if (sec<10) s$="0"+s$;
m$=intToString (min);
if (min<10) m$="0"+m$;
ss=s$+":"+m$;
cs.SetColor (255,250,250,0);
cs.SetTextSize (18);
cs.DrawText ("03:20",532,391);
cs.DrawText (ss,56,391);
cs.Update (); //显示绘出过程
}
// cs.SetColor (255,120,30,0); //clear text
//cs.DrawRect (100,300,320,367) ;
cs.SetColor (255,250,250,80);
cs.SetTextSize (40);
cs.DrawText (" 双色渐变进度条示例",160,530);
cs.Update ();
}//bar17()
bar16(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,150,150,150);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,250,250,0);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,290,450);
//**** draw program bar
L=70;
px=360;
py=300;
cs.SetColor(225,250,250,250); //底色
cs.DrawCircle(px,py,90);
cs.SetColor(225,240,240,240); //底色
cs.DrawCircle(px,py,88);
cs.SetColor(225,220,220,220);
cs.DrawCircle(px,py,51);
for (i=0;i<201;i++){ // Draw "O"
if ((i-i/10*10)==0) {
for (j=0;j<6;j++){
cs.SetStrokeWidth(6);
a=pi/200*(j+i)*2;
sx1=(float)(px+(L-15)*sin (a));
sy1=(float)(py-(L-15)*cos (a));
sx2=(float)(px+(L+14)*sin (a));
sy2=(float)(py-(L+14)*cos (a));
cs.SetColor(225,i*2-155,i+20,180); //draw bar line
cs.DrawLine (sx1,sy1,sx2,sy2); } }
cs.SetColor(225,100,100,100); //clear
cs.DrawCircle(px,py,51);
n=(int)(i/2) ;
if(n==100) {k=0; }else{k=10 ; }
ss=intToString (n)+"%" ;
cs.SetColor (255,250,250,0);
cs.SetTextSize (24);
cs.DrawText (ss,330+k,309);
cs.Update (); //显示绘出过程
} //draw bar
cs.SetColor (255,150,150,150); //clear text
cs.DrawRect (270,400,450,460) ;
cs.SetColor (255,250,250,80);
cs.SetTextSize (40);
cs.DrawText (" 环形进度条示例",110,530);
cs.Update ();
}//bar16()
bar15(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(3);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,150,150,150);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,250,250,0);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,290,450);
//**** draw program bar
L=70;
px=360;
py=300;
cs.SetColor(225,250,250,250); //底色
cs.DrawCircle(px,py,90);
cs.SetColor(225,20,20,20); //底色
cs.DrawCircle(px,py,88);
cs.SetColor(225,240,240,240);
cs.DrawCircle(px,py,51);
for (i=0;i<201;i++){ // Draw "O"
a=pi/200*i*2;
sx1=(float)(px+(L-15)*sin (a));
sy1=(float)(py-(L-15)*cos (a));
sx2=(float)(px+(L+14)*sin (a));
sy2=(float)(py-(L+14)*cos (a));
cs.SetColor(225,i+55,i+20,180); //draw bar line
cs.DrawLine (sx1,sy1,sx2,sy2);
cs.SetColor(225,240,240,240); //clear
cs.DrawCircle(px,py,51);
n=(int)(i/2) ;
if(n==100) {k=0; }else{k=10 ; }
ss=intToString (n)+"%" ;
cs.SetColor (255,250,20,0);
cs.SetTextSize (24);
cs.DrawText (ss,330+k,309);
cs.Update (); //显示绘出过程
} //draw bar
cs.SetColor (255,150,150,150); //clear text
cs.DrawRect (270,400,450,460) ;
cs.SetColor (255,250,250,80);
cs.SetTextSize (40);
cs.DrawText (" 环形进度条示例",110,530);
cs.Update ();
}//bar15()
bar14(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(1);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,150,150,150);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,250,250,0);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,290,450);
//**** draw program bar
L=70;
px=360;
py=300;
cs.SetColor(225,20,20,20); //底色
cs.DrawCircle(px,py,88);
cs.SetColor(225,240,240,240);
cs.DrawCircle(px,py,51);
cs.SetFillMode (0);//0不填色,1填色
cs.SetColor(225,200,200,200); //底色
cs.DrawCircle(px,py,82);
cs.SetFillMode (1);//0不填色,1填色
for (i=0;i<201;i++){ // Draw "O"
a=pi/200*i*2;
sx1=(float)(px+L*sin (a));
sy1=(float)(py-L*cos (a));
cs.SetColor(225,i+55,i+10,150);
cs.DrawCircle(sx1,sy1,13);
cs.SetColor(225,250,20,50);
cs.DrawCircle(sx1,sy1,9);
cs.SetColor(225,240,240,240); //clear
cs.DrawCircle(px,py,51);
n=(int)(i/2) ;
if(n==100) {k=0; }else{k=10 ; }
ss=intToString (n)+"%" ;
cs.SetColor (255,250,20,0);
cs.SetTextSize (24);
cs.DrawText (ss,330+k,309);
cs.Update (); //显示绘出过程
} //draw bar
cs.SetColor (255,150,150,150); //clear text
cs.DrawRect (270,400,450,460) ;
cs.SetColor (255,250,250,80);
cs.SetTextSize (40);
cs.DrawText (" 环形进度条示例",110,530);
cs.Update ();
}//bar14()
bar13(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,150,150,150);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,250,250,0);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,290,450);
//**** draw program bar
L=70;
px=360;
py=300;
cs.SetColor(225,200,200,200); //底色
cs.DrawCircle(px,py,90);
cs.SetColor(225,240,240,240);
cs.DrawCircle(px,py,50);
for (i=0;i<201;i++){ // Draw "O"
a=pi/200*i*2;
sx1=(float)(px+L*sin (a));
sy1=(float)(py-L*cos (a));
cs.SetColor(225,i+50,200-i,i);
cs.DrawCircle(sx1,sy1,13);
cs.SetColor(225,250,200,50);
cs.DrawCircle(sx1,sy1,9);
cs.SetColor(225,240,240,240); //clear
cs.DrawCircle(px,py,50);
n=(int)(i/2) ;
if(n==100) {k=0; }else{k=10 ; }
ss=intToString (n)+"%" ;
cs.SetColor (255,250,20,0);
cs.SetTextSize (24);
cs.DrawText (ss,330+k,309);
cs.Update (); //显示绘出过程
} //draw bar
cs.SetColor (255,150,150,150); //clear text
cs.DrawRect (270,400,450,460) ;
cs.SetColor (255,250,250,80);
cs.SetTextSize (40);
cs.DrawText (" 环形进度条示例",220,500);
cs.Update ();
}//bar13()
bar12(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,150,150,150);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,250,250,0);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("LOADING......" ,100,350);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,0,20,20);
cs.DrawCircle (i*2+112,384,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,250,250,250);
cs.DrawCircle (i*2+114,385,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,220,220,220);
cs.DrawCircle (i*2+113,384,18); }
for (i=0;i<201;i++){ //底色
cs.SetColor (255,150,150,150);
cs.DrawCircle (i*2+113,385,5); }
cs.Update ();
for (i=0;i<201;i++){ //进度条 (12)
cs.SetColor (255,220,220,220); //mask
cs.DrawOval (i*2+112,385,9,13,0);
cs.SetColor (255,55+i,10+i,150);
cs.DrawCircle (i*2+110,385,8);
cs.SetColor (255,55,10,50);
// cs.DrawCircle (i*2+110,385,3);
for (d=0;d<12;d++){ //变色珠
cs.SetColor (255,255-d*12,125,100);
cs.DrawCircle (i*2+115,385,11-d); }
cs.SetColor (255,150,150,150); //clear
cs.DrawRect(537,367,620,403) ;
n=(int)(i /2) ;
if(n<100) {k=15; }else{k=0 ; }
ss=intToString (n)+" %" ;
cs.SetColor (255,250,250,0);
cs.SetTextSize (26);
cs.DrawText (ss,540+k,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,150,150,150); //clear text
cs.DrawRect (100,300,320,358) ;
cs.SetColor (255,250,250,0);
cs.SetTextSize (40);
cs.DrawText (" 双色渐变进度条示例",110,530);
cs.Update ();
}//bar12()
bar11(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,150,150,150);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,250,250,0);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("LOADING......" ,100,350);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,0,20,20);
cs.DrawCircle (i*2+112,384,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,250,250,250);
cs.DrawCircle (i*2+114,385,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,220,220,220);
cs.DrawCircle (i*2+113,384,18); }
for (i=0;i<201;i++){ //底色
cs.SetColor (255,80,220,220);
cs.DrawCircle (i*2+113,385,3); }
cs.Update ();
for (i=0;i<201;i++){ //进度条 (11)
cs.SetColor (255,255-i/2,i+50,120);
cs.DrawCircle (i*2+113,385,9);
cs.SetColor (255,255-i/4,i+55,90);
cs.DrawCircle (i*2+109,385,8);
cs.SetColor (255,220,220,220); //mask
cs.DrawOval (i*2+111,385,8,12,0);
for (d=0;d<12;d++){ //变色珠
cs.SetColor (255,255-d*10,105,205);
cs.DrawCircle (i*2+115,385,11-d); }
cs.SetColor (255,150,150,150); //clear
cs.DrawRect(537,367,620,403) ;
n=(int)(i /2) ;
if(n<100) {k=15; }else{k=0 ; }
ss=intToString (n)+" %" ;
cs.SetColor (255,250,250,0);
cs.SetTextSize (26);
cs.DrawText (ss,540+k,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,150,150,150); //clear text
cs.DrawRect (100,300,320,358) ;
cs.SetColor (255,200,200,80);
cs.SetTextSize (40);
cs.DrawText (" 双色渐变进度条示例",110,530);
cs.Update ();
}//bar11()
bar10(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,0,120,220);
cs.DrawCircle (i*2+113,385,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,120,120,120);
cs.DrawCircle (i*2+113,385,17); }
for (i=0;i<201;i++){ //底色
cs.SetColor (255,80,220,220);
cs.DrawCircle (i*2+113,385,3); }
cs.Update ();
for (i=0;i<201;i++){ //进度条 (10)
cs.SetColor (255,255-i/2,i+50,120);
cs.DrawCircle (i*2+113,385,9);
cs.SetColor (255,255-i/4,i+55,90);
cs.DrawCircle (i*2+109,385,8);
cs.SetColor (255,0,120,120);
cs.DrawCircle (i*2+110,385,7);
cs.SetColor (255,120,120,120);
cs.DrawOval (i*2+111,385,8,12,0);
for (d=0;d<12;d++){ //变色珠
cs.SetColor (255,255-d*10,255-d*10,255);
cs.DrawCircle (i*2+115,385,11-d); }
cs.SetColor (255,250,250,250); //clear
cs.DrawRect(535,367,600,403) ;
n=(int)(i /2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,540,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,0,120,80);
cs.SetTextSize (40);
cs.DrawText (" 双色渐变进度条示例",110,530);
cs.Update ();
}//bar10()
bar9(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetColor (255,120,120,120);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,0,120,220);
cs.DrawCircle (i*2+113,385,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,220,220,220);
cs.DrawCircle (i*2+113,385,17); }
for (i=0;i<201;i++){ //底色
cs.SetColor (255,80,120,220);
cs.DrawCircle (i*2+113,385,4); }
cs.Update ();
for (i=0;i<201;i++){ //进度条 (9)
cs.SetColor (255,255-i/5,i+50,120);
cs.DrawCircle (i*2+113,380,4);
cs.SetColor (255,255-i,i/2+50,120);
cs.DrawCircle (i*2+114,386,8);
cs.SetColor (255,255-i/2,i+50,120);
cs.DrawCircle (i*2+112,385,6);
cs.SetColor (255,250,20,20);
cs.DrawCircle (i*2+113,385,5);
cs.SetColor (255,250,250,250); //clear
cs.DrawRect(535,367,600,403) ;
n=(int)(i /2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,540,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,0,120,80);
cs.SetTextSize (40);
cs.DrawText (" 双色渐变进度条示例",110,530);
cs.Update ();
}//bar9()
bar8(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetColor (255,120,120,120);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,0,120,220);
cs.DrawCircle (i*2+113,385,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,220,220,220);
cs.DrawCircle (i*2+113,385,17); }
for (i=0;i<201;i++){ //底色
cs.SetColor (255,80,120,220);
cs.DrawCircle (i*2+113,385,5); }
cs.Update ();
for (i=0;i<201;i++){ //进度条 (8)
cs.SetColor (255,255-i/2,i+50,120);
cs.DrawCircle (i*2+113,385,9);
cs.SetColor (255,255-i ,i+55,90);
cs.DrawCircle (i*2+110,385,7);
cs.SetColor (255,255,0,0);
cs.DrawCircle (i*2+113,385,5);
cs.SetColor (255,250,250,250); //clear
cs.DrawRect(535,367,600,403) ;
n=(int)(i /2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,540,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,0,120,80);
cs.SetTextSize (40);
cs.DrawText (" 双色渐变进度条示例",110,530);
cs.Update ();
}//bar8 ()
bar7(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetColor (255,120,120,120);
for (i=0;i<202;i++){ //进度条框底色
cs.SetColor (255,0,120,220);
cs.DrawCircle (i*2+113,385,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,220,220,220);
cs.DrawCircle (i*2+113,385,17); }
for (i=0;i<201;i++){ //底色
cs.SetColor (255,80,120,220);
cs.DrawCircle (i*2+113,385,5); }
cs.Update ();
for (i=0;i<201;i++){ //进度条 (7)
cs.SetColor (255,255-i/2,i+50,120);
cs.DrawCircle (i*2+113,385,9);
cs.SetColor (255,255-i ,i+55,90);
cs.DrawCircle (i*2+110,385,7);
cs.SetColor (255,250,250,250); //clear
cs.DrawRect(535,367,600,403) ;
n=(int)(i /2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,540,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,0,120,80);
cs.SetTextSize (40);
cs.DrawText (" 三色渐变进度条示例",110,530);
cs.Update ();
}//bar7 ()
bar6(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,50,50,100);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,290,420);
//**** draw program bar
L=60;
px=360;
py=300;
t=0;
replay: //
for (i=-2;i<201;i++){ // Draw "O"
if ((i-i/4*4)==0) {
cs.SetStrokeWidth(3);
a=pi/200*(j+i)*2;
sx1=(float)(px+(L-17)*sin (a));
sy1=(float)(py-(L-17)*cos (a));
sx2=(float)(px+(L+12)*sin (a));
sy2=(float)(py-(L+12)*cos (a));
cs.SetColor(225,i*2+55,i+50,160); //draw bar line
cs.DrawLine (sx1,sy1,sx2,sy2); } // }
cs.SetColor(225,250,250,250); //clear
cs.DrawCircle(px,py,40);
n=i/10+t*20 ;
if(n==100) {k=0; }else{k=10 ; }
ss=intToString (n)+"%" ;
cs.SetColor (255,20,150,100);
cs.SetTextSize (24);
cs.DrawText (ss,330+k,309);
cs.Update (); //显示绘出过程
} //draw bar
if (n<100){
cs.SetColor(225,250,250,250); //clear
cs.DrawCircle(px,py,90); }
t=t+1;
if (t<5) goto replay; //replay 5 times
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (270,390,450,460) ;
cs.SetColor (255,250,50,50);
cs.SetTextSize (30);
cs.DrawText (" 环形进度条示例",255,500);
cs.Update ();
}//bar6()
bar5(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetColor (255,120,120,120);
for (i=0;i<202;i++){ //底色
cs.SetColor (255,0,0,0);
cs.DrawCircle (i*2+113,385,19); }
for (i=0;i<202;i++){ //底色
cs.SetColor (255,220,220,220);
cs.DrawCircle (i*2+113,385,17); }
cs.Update ();
for (i=0;i<201;i++){ //进度条 (5)
cs.SetColor (255,255-i/2 ,i+50,120);
cs.DrawCircle (i*2+113,385,13);
cs.SetColor (255,250,250,250); //clear
cs.DrawRect(535,367,600,403) ;
n=(int)(i /2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,540,393);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,0,120,80);
cs.SetTextSize (40);
cs.DrawText (" 三色渐变进度条示例",110,530);
cs.Update ();
}//bar5 ()
bar4(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(1);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetFillMode (0);//0不填色,1填色
cs.SetColor (255,50,50,50); //框线
cs.DrawRect (93,363,512,407) ;
cs.Update ();
for (i=0;i<51;i++){ //进度条 (4)
cs.SetFillMode (0);//0不填色,1填色
cs.SetColor (255,20,200,10);
cs.DrawRect (i*8+100,370,i*8+106,400);
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,250,0,20);
cs.DrawRect (i*8+102,372,i*8+105,399);
//sleep (10);
cs.SetColor (255,250,250,250); //clear
cs.DrawRect (515,367,588,403) ;
n=(int)(i *2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,525,395);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,150,80,40);
cs.SetTextSize (40);
cs.DrawText (" 双色条形进度条示例",110,530);
cs.Update ();
}//bar4()
bar3(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(1);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetFillMode (0);//0不填色,1填色
cs.SetColor (255,50,50,50);
cs.DrawRect (93,363,512,407) ;
cs.Update ();
for (i=0;i<51;i++){ //进度条 (1)
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,20,0,200);
cs.DrawRect (i*8+100,370,i*8+106,400);
// sleep (10);
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,250,250,250); //clear
cs.DrawRect (515,367,588,403) ;
n=(int)(i *2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,525,395);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,150,80,40);
cs.SetTextSize (40);
cs.DrawText (" 单色条形进度条示例",110,530);
cs.Update ();
}//bar3()
bar2(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,250,250,250);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetFillMode (0);//0不填色,1填色
cs.SetColor (255,50,50,50);
cs.DrawRect (93,365,508,405) ;
cs.Update ();
cs.SetFillMode (1);//0不填色,1填色
for (i=0;i<201;i++){ //进度条 (2)
cs.SetColor (255,255-i/2,200-i,i);
cs.DrawLine (i*2+100,370,i*2+100,400);
cs.SetColor (255,250,250,250); //clear
cs.DrawRect (512,367,588,403) ;
n=(int)(i /2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,515,395);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,250,250,250); //clear text
cs.DrawRect (100,300,300,358) ;
cs.SetColor (255,150,80,40);
cs.SetTextSize (40);
cs.DrawText (" 三色渐变进度条示例",110,530);
cs.Update ();
}//bar2 ()
bar1(){
cs.SetFillMode (1);//0不填色,1填色
cs.SetStrokeWidth(2);
cs.SetColor (255,50,50,50); //background
cs.DrawRect (0,600,720,900);
cs.SetColor (255,220,220,220);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (26);
cs.SetColor (255,20,20,140);
cs.DrawText (" 绘制进度条示例 ",20,35);
s=intToString (sn);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.DrawText ("Loading......" ,100,350);
cs.SetFillMode (0);//0不填色,1填色
cs.SetColor (255,50,50,50);
cs.DrawRect (93,365,508,405) ;
// cs.SetFillMode (1);//0不填色,1填色
cs.SetTextSize (48);
cs.SetTextStyle(1);
ss=" □□□□工资管理系统 ”;
cs.SetColor (255,50,250,50);
cs.DrawText (ss,100,150);
cs.SetFillMode (1);//0不填色,1填色
cs.SetColor (255,20,50,200);
cs.DrawText (ss,100,150);
cs.SetTextSize (26);
cs.SetColor (255,250,250,250);
cs.DrawRect (255,215,575,258);
cs.SetColor (255,150,50,150);
cs.DrawText ("User Name : " ,110,250);
cs.DrawText ("My Name " ,264,245);
cs.SetColor (255,250,250,250);
cs.DrawRect (255,265,575,308);
cs.SetColor (255,150,50,150);
cs.DrawText ("Password : " ,110,300);
cs.DrawText ("********* " ,264,300);
//draw button 绘制渐变色按钮
cs.SetColor (255,250,250,250);
cs.DrawRect (130,428,301,491);
cs.DrawRect (350,428,521,491);
for (i=1;i<60;i++){ //按钮渐变色
cs.SetColor (255,250-i*4,240-i*3,200-i*3);
cs.DrawLine (132,430+i,300,430+i);
cs.DrawLine (352,430+i,520,430+i);
}
cs.SetColor(255,255,250,0);
cs.SetTextStyle (0);
cs.SetTextSize (32);
cs.DrawText ("Log in",165,467);
cs.DrawText (" Exit",387,467);
cs.Update ();
cs.SetFillMode (1);//0不填色,1填色
for (i=0;i<201;i++){ //进度条 (3)
cs.SetColor (150,255-i,i+10,i);
cs.DrawLine (i*2+100,370,i*2+100,400);
cs.SetColor (255,240,240,240); //clear
cs.DrawRect (512,367,590,403) ;
n=(int)(i /2) ;
ss=intToString (n)+" %" ;
cs.SetColor (255,250,20,20);
cs.SetTextSize (26);
cs.DrawText (ss,518,395);
cs.Update (); //显示绘出过程
}
cs.SetColor (255,220,220,220); //clear text
cs.DrawRect (100,320,300,358) ;
cs.SetColor (255,240,120,80);
cs.SetTextSize (36);
cs.DrawText (" 三色渐变进度条示例",80,550);
cs.Update ();
}//bar1 ()
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 ==
C语言绘画示例-进度条相关推荐
- Xamarin XAML语言教程构建进度条ProgressBar
Xamarin XAML语言教程构建进度条ProgressBar Xamarin XAML语言教程构建进度条ProgressBar,ProgressBar被称为进度条,它类似于没有滑块的滑块控件.进度 ...
- 30天自制操作系统——第四天使用C语言制作操作系统进度条
昨天已经让画面显示黑屏了,但是黑屏太没意思,今天来让画面画点东西吧. 今天的任务还是比较有趣的,主要包括内存写入.画面显示条纹图案.设定色号.绘制矩形,最后制作一个进度条. 每个大标题下的代码,都在文 ...
- 各种语言实现的进度条
AVAJAVA Web Tutorials:http://www.avajava.com/tutorials/lessons/how-do-i-monitor-the-progress-of-a-fi ...
- Android进度条示例
在Android中,进度条可用于告诉用户该任务需要较长时间才能完成. 在本教程中,我们向您展示如何显示进度条对话框以告诉用户您的任务正在运行,以及如何增加进度条状态直到任务完成. 注意 有关详细说明, ...
- C语言实现进度条彩色变化
[C语言]实现一个变色的进度条 原创 2017年03月31日 20:39:30 标签: linux / C语言 / 376 编辑 删除 实现一个如上的进度条 要求 1.依次多打印一个'#' 2.并后面 ...
- shell下的进度条和最大最小平均值
进度条 C语言下的进度条参考我原来的一篇blog->进度条 function proc() {i=0 str=''arr=('|' '/' '-' '\\')index=0while [ $i ...
- 如何用HTML语言设计进度条,html5代码如何实现进度条功能?(示例)
本篇文章主要介绍html5代码如何实现进度条功能,希望对大家有所帮助. html5代码实现进度条功能具体代码示例如下:/*实现进度条的功能*/ 下载进度: /*js代码*/ var pg=docume ...
- Xamarin XAML语言教程通过ProgressTo方法对进度条设置
Xamarin XAML语言教程通过ProgressTo方法对进度条设置 在ProgressBar中定义了一个ProgressTo方法,此方法也可以用来对进度条当前的进行进行设置,ProgressTo ...
- Xamarin XAML语言教程使用属性设置进度条的当前进度
Xamarin XAML语言教程使用属性设置进度条的当前进度 在图12.19~12.21中我们看到的是没有实现加载的进度条,即进度条的当前进度为0,如果开发者想要修改当前进度,可以使用两种方式:一种是 ...
- Xamarin XAML语言教程使用方法设置进度条进度
Xamarin XAML语言教程使用方法设置进度条进度 在ProgressBar中定义了一个ProgressTo方法,此方法也可以用来对进度条当前的进行进行设置,ProgressTo与Progress ...
最新文章
- OpenCV支持中文字符输出实现
- 添加MySql数据库超时设置的相关问题
- python基础网易_十年Python大牛花了三天总结出来的python基础知识实例,超详细!...
- windows 安装 reviewboard
- python小项目推荐项目-推荐 10 个有趣的 Python 项目
- 网站运维技术与实践之服务器监测常用命令
- 计算机二级考试需要怎么备考,计算机二级ms office应该怎么备考 考试内容是什么...
- 真的要做一辈子的程序员吗?来自10年程序员的心声
- 《React 学习之道》The Road to learn React (简体中文版)
- Python中append()和extend方法的使用和区别
- Leetcode:415. Add Strings
- php 工厂模式作用,PHP工厂模式的好处概述
- 人工智能(腾讯AI)-身份证识别技术使用接口说明
- Flink中Table Api和SQL(二)
- java list 取第一个,从Java LinkedList获取第一个和最后一个元素
- 盖茨与鲍尔默相处:放权给怒吼“奶妈”
- 多进程统计策略盈亏分布——从零到实盘12
- Juniper防火墙无法登陆的问题解决
- 由IP6K防尘和IPX9K防水组合的IP6K9K
- MFC——Listcontrol 添加背景颜色