[ucgui] 彩色条函数

 

 

 1 /*
 2 颜色条
 3 */
 4 void ShowColorBar(void)
 5 {
 6     int x0 = 60, y0 = 40, yStep = 15, i;
 7     int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
 8     int xsize = LCD_GetDevCap(LCD_DEVCAP_XSIZE) - x0;
 9     GUI_SetFont(&GUI_Font13HB_1);
10     GUI_DispStringHCenterAt("μC/GUI-sample:Show color bars", 160, 0);
11     GUI_SetFont(&GUI_Font8x8);
12     GUI_SetColor(GUI_WHITE);
13     GUI_SetBkColor(GUI_BLACK);
14     #if(LCD_FIXEDPALETTE)
15         GUI_DispString("Fixed palette: ");
16         GUI_DispDecMin(LCD_FIXEDPALETTE);
17     #endif
18     GUI_DispStringAt("Red", 0, y0 + yStep);
19     GUI_DispStringAt("Green", 0, y0 + 3 * yStep);
20     GUI_DispStringAt("Blue", 0, y0 + 5 * yStep);
21     GUI_DispStringAt("Grey", 0, y0 + 6 * yStep);
22     GUI_DispStringAt("Yellow", 0, y0 + 8 * yStep);
23     GUI_DispStringAt("Cyan", 0, y0 + 10 * yStep);
24     GUI_DispStringAt("Magenta", 0, y0 + 12 * yStep);
25     for(i=0; i < xsize; i++)
26     {
27         U16 cs =(255 *(U32)i) / xsize;
28         U16 x = x0 + i;
29         /* 红色 */
30         GUI_SetColor(cs);
31         GUI_DrawVLine(x, y0, y0 +yStep - 1);
32         GUI_SetColor(0xff +(255 - cs) * 0x10100L);
33         GUI_DrawVLine(x, y0 +yStep, y0 + 2 * yStep - 1);
34         /* 绿色 */
35         GUI_SetColor(cs<<8);
36         GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1);
37         GUI_SetColor(0xff00 +(255 - cs) * 0x10001L);
38         GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1);
39         /* 蓝色 */
40         GUI_SetColor(cs * 0x10000L);
41         GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1);
42         GUI_SetColor(0xff0000 +(255 - cs) * 0x101L);
43         GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1);
44         /* 灰色 */
45         GUI_SetColor((U32)cs * 0x10101L);
46         GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1);
47         /* 黄色 */
48         GUI_SetColor(cs * 0x101);
49         GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1);
50         GUI_SetColor(0xffff +(255 - cs) * 0x10000L);
51         GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1);
52         /* 青色 */
53         GUI_SetColor(cs * 0x10100L);
54         GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1);
55         GUI_SetColor(0xffff00 +(255 - cs) * 0x1L);
56         GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep - 1);
57         /* 洋红 */
58         GUI_SetColor(cs * 0x10001);
59         GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1);
60         GUI_SetColor(0xff00ff +(255 - cs) * 0x100L);
61         GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep - 1);
62     }
63 }

 

posted @ 2014-04-22 22:34  beautifulzzzz  阅读(836)  评论(0编辑  收藏  举报