|
这是一个3D的填充矩形,可以用来做按钮.
void GUI_3D_Rectangle(int x_addr,int y_addr,int dx,int dy,int Bright_RGB,int Dark_RGB,int Light_Way)
{
U16 Left_RGB,Up_RGB,Right_RGB,Down_RGB,RGB;
U8 r0,g0,b0,r1,g1,b1;
////
r0=(Bright_RGB>>Red)&0x1f;
g0=(Bright_RGB>>Green)&0x3f;
b0=(Bright_RGB>>Blue)&0x1f;
r1=(Dark_RGB>>Red)&0x1f;
g1=(Dark_RGB>>Green)&0x3f;
b1=(Dark_RGB>>Blue)&0x1f;
RGB=RGB565((r0+r1)>>1,(g0+g1)>>1,(b0+b1)>>1);
GUI_FillRectangle(x_addr+2,y_addr+2,dx-3,dy-3,RGB);
////
switch(Light_Way)
{
case Left:
Left_RGB=Bright_RGB;
Up_RGB=RGB;
Right_RGB=Dark_RGB;
Down_RGB=RGB;
break;
////////
case Up:
Left_RGB=RGB;
Up_RGB=Bright_RGB;
Right_RGB=RGB;
Down_RGB=Dark_RGB;
break;
////////
case Right:
Left_RGB=Dark_RGB;
Up_RGB=RGB;
Right_RGB=Bright_RGB;
Down_RGB=RGB;
break;
////////
case Down:
Left_RGB=RGB;
Up_RGB=Dark_RGB;
Right_RGB=RGB;
Down_RGB=Bright_RGB;
break;
////////
case Left_Up:
Left_RGB=Bright_RGB;
Up_RGB=Bright_RGB;
Right_RGB=Dark_RGB;
Down_RGB=Dark_RGB;
break;
////////
case Right_Up:
Left_RGB=Dark_RGB;
Up_RGB=Bright_RGB;
Right_RGB=Bright_RGB;
Down_RGB=Dark_RGB;
break;
////////
case Left_Down:
Left_RGB=Bright_RGB;
Up_RGB=Dark_RGB;
Right_RGB=Dark_RGB;
Down_RGB=Bright_RGB;
break;
////////
case Right_Down:
Left_RGB=Dark_RGB;
Up_RGB=Dark_RGB;
Right_RGB=Bright_RGB;
Down_RGB=Bright_RGB;
break;
////////
default: return;
}
////
GUI_Line(x_addr,y_addr,x_addr,y_addr+dy,Left_RGB); //Left(Outside).
GUI_Line(x_addr+1,y_addr+1,x_addr+1,y_addr+dy-2,Left_RGB); //Left(Inside);
GUI_Line(x_addr,y_addr,x_addr+dx,y_addr,Up_RGB); //Up(Outside).
GUI_Line(x_addr+1,y_addr+1,x_addr+dx-2,y_addr+1,Up_RGB); //Up(Inside);
GUI_Line(x_addr+dx,y_addr,x_addr+dx,y_addr+dy,Right_RGB); //Right(Outside).
GUI_Line(x_addr+dx-1,y_addr+1,x_addr+dx-2,y_addr+dy,Right_RGB); //Right(Inside).
GUI_Line(x_addr+1,y_addr+dy,x_addr+dx,y_addr+dy,Down_RGB); //Down(Outside).
GUI_Line(x_addr+2,y_addr+dy-1,x_addr+dx-1,y_addr+dy,Down_RGB); //Down(Inside);
} |
|