#include"gui.h"
; ^5 @& {5 W" k# {- [) N. p
//---汉字的字库头文件---//
#include"charcode.h"
) J4 Q1 b/ G9 Z, s8 w+ s8 O
//---如果要显示图片就添加这个头文件---//
#ifdef PICTURE_SHOW
0 ?* j7 W7 g0 ?$ X
#include"picture.h"
8 x; H, c! [6 x' H
#endif
( }; e2 `0 N8 R( ?8 N$ _1 Q, d2 N
/****************************************************************************
*函数名:GUI_Dot
*输 入:x:点的X坐标;
* * y:点的Y坐标
* * color:点的颜色
*输 出:
*功 能:给单个像素涂上颜色。
****************************************************************************/
g" P7 g+ H4 _* c/ n. {% c
void GUI_Dot(uint x, uint y, uint color)
{
uchar i;
0 k4 z3 S8 J3 @
TFT_SetWindow(x-1, y, x+2, y+2); //单个像素
- f M, l7 U# M$ U$ j$ O
for(i=0; i<16; i++)
{
TFT_WriteColorData(color) ;
//TFT_WriteData(color);
}
}
. {( X0 ^2 ~! X
///****************************************************************************
//*函数名:GUI_Box
//*输 入:sx:起始X坐标, sy:其实Y坐标,
//* * ex:终止X坐标, ey:终止Y坐标,
//* * color:方框的颜色
//*输 出:
//*功 能:给一个区域涂上颜色。
//****************************************************************************/
//void GUI_Box(uint sx, uint sy, uchar ex, uint ey, uint color)
//{
// uint temp;
// TFT_SetWindow(sx, sy, ex, ey);
// sx = ex - sx + 1;
// sy = ey - sy + 1;
// while (sx--)
// {
// temp = sy;
// while (temp--)
// {
// TFT_WriteData(color);
// }
// }
//}
$ g+ i: Y- e$ S( b% q* b
/****************************************************************************
*函数名:GUI_Line
*输 入:xStart:线的起始X坐标,
* * yStart:线的其实Y坐标,
* * xEnd:线的终止X坐标,
* * yEnd:线的终止Y坐标,
* * color:线条的颜色
*输 出:
*功 能:画一条直线
****************************************************************************/
. ^0 a4 q1 T% K' e
void GUI_Line(uint xStart, uint yStart, uchar xEnd, uint yEnd, uint color)
{
uint t;
int xerr = 0, yerr = 0, delta_x, delta_y, distance;
int incx, incy;
uint row, col;
delta_x = xEnd - xStart;//计算坐标增量
delta_y = yEnd - yStart;
col = xStart;
row = yStart;
if (delta_x > 0)
{
incx=1;//设置单步方向
}
else
{
if (delta_x == 0)
{
incx = 0;//垂直线
}
else
{
incx = -1;
delta_x = -delta_x;
}
}
if (delta_y > 0)
{
incy = 1;
}
else
{
if (delta_y == 0)
{
incy = 0;//水平线
}
else
{
incy = -1;
delta_y = -delta_y;
}
}
if (delta_x > delta_y)
{
distance = delta_x;//选取基本增量坐标轴
}
else
{
distance = delta_y;
}
for (t=0; t<=distance+1; t++)
{ //画线输出
GUI_Dot(col, row, color);
xerr += delta_x;
yerr += delta_y;
if(xerr > distance)
{
xerr -= distance;
col += incx;
}
if(yerr > distance)
{
yerr -= distance;
row += incy;
}
}
}
3 o2 f# G# o+ R, K% \/ S
/****************************************************************************
*函数名:GUI_WriteCnChar
*输 入:x:显示起始X坐标
* * y:显示起始Y坐标
* * *cn:要显示的字符串
* * wordColor:字体的颜色
* * backColor:背景颜色
*输 出:
*功 能:写二号楷体汉字
****************************************************************************/
; z' o4 C5 x+ Q% e# t! q
#ifdef CHAR32_SHOW
2 }: ?$ Q, m7 L. s/ ?
void GUI_Write32CnChar(uint x, uint y, uchar *cn, uint wordColor, uint backColor)
5 j# B. ]2 r0 V* Y% p5 L" B$ c
…………限于本文篇幅 余下代码请下载附件…………
% v1 p. ^( ^; R1 c4 Z& u
5 q$ b9 ~$ @! n) y2 O s