[ucgui] 彩色条函数

时间:2023-03-08 15:53:03
[ucgui] 彩色条函数
 /*
颜色条
*/
void ShowColorBar(void)
{
int x0 = , y0 = , yStep = , i;
int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
int xsize = LCD_GetDevCap(LCD_DEVCAP_XSIZE) - x0;
GUI_SetFont(&GUI_Font13HB_1);
GUI_DispStringHCenterAt("μC/GUI-sample:Show color bars", , );
GUI_SetFont(&GUI_Font8x8);
GUI_SetColor(GUI_WHITE);
GUI_SetBkColor(GUI_BLACK);
#if(LCD_FIXEDPALETTE)
GUI_DispString("Fixed palette: ");
GUI_DispDecMin(LCD_FIXEDPALETTE);
#endif
GUI_DispStringAt("Red", , y0 + yStep);
GUI_DispStringAt("Green", , y0 + * yStep);
GUI_DispStringAt("Blue", , y0 + * yStep);
GUI_DispStringAt("Grey", , y0 + * yStep);
GUI_DispStringAt("Yellow", , y0 + * yStep);
GUI_DispStringAt("Cyan", , y0 + * yStep);
GUI_DispStringAt("Magenta", , y0 + * yStep);
for(i=; i < xsize; i++)
{
U16 cs =( *(U32)i) / xsize;
U16 x = x0 + i;
/* 红色 */
GUI_SetColor(cs);
GUI_DrawVLine(x, y0, y0 +yStep - );
GUI_SetColor(0xff +( - cs) * 0x10100L);
GUI_DrawVLine(x, y0 +yStep, y0 + * yStep - );
/* 绿色 */
GUI_SetColor(cs<<);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
GUI_SetColor(0xff00 +( - cs) * 0x10001L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
/* 蓝色 */
GUI_SetColor(cs * 0x10000L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
GUI_SetColor(0xff0000 +( - cs) * 0x101L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
/* 灰色 */
GUI_SetColor((U32)cs * 0x10101L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
/* 黄色 */
GUI_SetColor(cs * 0x101);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
GUI_SetColor(0xffff +( - cs) * 0x10000L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
/* 青色 */
GUI_SetColor(cs * 0x10100L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
GUI_SetColor(0xffff00 +( - cs) * 0x1L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
/* 洋红 */
GUI_SetColor(cs * 0x10001);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
GUI_SetColor(0xff00ff +( - cs) * 0x100L);
GUI_DrawVLine(x, y0 + * yStep, y0 + * yStep - );
}
}