专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
LCD
请问有没有谁填充过矩形区域(圆角)的LCD屏?
2020-01-03 19:08
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
21603
22
22
我现在使用的是320*240(横屏),方形的按键有点难看,于是就想到用圆角的按键,带圆角的框是画出来了,但按下的时候,不知道如何填充带圆角的矩形区域。有过这样应用的朋友说说思路咯。
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
22条回答
worksnfkpynn99
2020-01-05 09:24
/***********************************************************************************************************************
* 函数名: LCD_DrawCircleRectangle
* 参 数: x0 :X坐标
* y0 :Y坐标
* Length :长度
* wide :方向(Horizontal,Vertical)
* r :圆角半径
* 返 回: 无
* 功 能: 在LCD上画圆角矩形
*************************************************************************************************************************/
void LCD_DrawCircleRectangle(unsigned short x0,unsigned char y0,unsigned short Length,unsigned char wide,unsigned char r)
{
int a,b;
int di;
unsigned char QUA_Second_y0,QUA_Third_y0;
unsigned short QUA_Third_x0,QUA_Four_x0;
x0 = x0+r;
y0 = y0+r;
Length = Length-2*r;
wide = wide-2*r;
a=0;
b=r;
di=3-2*r;
while(a<=b)
{
//第一象限
LCD_DrawPoint(x0-a,y0-b); //2
LCD_DrawPoint(x0-b,y0-a); //3
//第二象限
QUA_Second_y0 = y0+wide;
LCD_DrawPoint(x0-a,QUA_Second_y0+b); //1
LCD_DrawPoint(x0-b,QUA_Second_y0+a); //7
//第三象限
QUA_Third_y0 = y0+wide;
QUA_Third_x0 = x0+Length;
LCD_DrawPoint(QUA_Third_x0+a,QUA_Third_y0+b); //6
LCD_DrawPoint(QUA_Third_x0+b,QUA_Third_y0+a); //4
//第四象限
QUA_Four_x0 = x0+Length;
LCD_DrawPoint(QUA_Four_x0+a,y0-b); //5
LCD_DrawPoint(QUA_Four_x0+b,y0-a); //0
a++;
if(di<0) di +=4*a+6;
else
{
di+=10+4*(a-b);
b--;
}
//LCD_DrawPoint(x0+a,y0+b);
}
LCD_DrawLine(x0-r,y0,wide,Vertical);//(6,10,77,Vertical);
LCD_DrawLine(x0+r+Length,y0,wide,Vertical);//(192,10,77,Vertical);
LCD_DrawLine(x0,y0-r,Length,Horizontal);//(6,10,186,Horizontal);
LCD_DrawLine(x0,y0+wide+r,Length,Horizontal);//(6,87,186,Horizontal);
}
/***********************************************************************************************************************
* 函数名: LCD_FillCircle
* 参 数: x0 :X坐标
* y0 :Y坐标
* Length :长度
* wide :方向(Horizontal,Vertical)
* r :圆角半径
* color :填充 {MOD}
* 返 回: 无
* 功 能: 用指定 {MOD}填充圆角矩形区域
*************************************************************************************************************************/
void LCD_FillCircle(unsigned short x0,unsigned char y0,unsigned short Length,unsigned char wide,unsigned char r,unsigned short color)
{
int a,b;
int di;
unsigned char QUA_Second_y0,QUA_Third_y0;
unsigned short QUA_Third_x0,QUA_Four_x0;
x0 = x0+r;
y0 = y0+r;
Length = Length-2*r;
wide = wide-2*r;
a=0;
b=r;
di=3-2*r;
FontSet(3,color,1);
while(a<=b)
{
//第一象限
LCD_DrawPoint(x0-a,y0-b); //2
LCD_DrawPoint(x0-b,y0-a); //3
//第二象限
QUA_Second_y0 = y0+wide;
LCD_DrawPoint(x0-a,QUA_Second_y0+b); //1
LCD_DrawPoint(x0-b,QUA_Second_y0+a); //7
//第三象限
QUA_Third_y0 = y0+wide;
QUA_Third_x0 = x0+Length;
LCD_DrawPoint(QUA_Third_x0+a,QUA_Third_y0+b); //6
LCD_DrawPoint(QUA_Third_x0+b,QUA_Third_y0+a); //4
//第四象限
QUA_Four_x0 = x0+Length;
LCD_DrawPoint(QUA_Four_x0+a,y0-b); //5
LCD_DrawPoint(QUA_Four_x0+b,y0-a); //0
LCD_DrawLine(x0-a,y0-b,(QUA_Four_x0+a)-(x0-a),Horizontal);
LCD_DrawLine(x0-b,y0-a,(QUA_Four_x0+b)-(x0-b),Horizontal);
LCD_DrawLine(x0-a,QUA_Second_y0+b,(QUA_Third_x0+a)-(x0-a),Horizontal);
LCD_DrawLine(x0-b,QUA_Second_y0+a,(QUA_Four_x0+b)-(x0-b),Horizontal);
a++;
if(di<0) di +=4*a+6;
else
{
di+=10+4*(a-b);
b--;
}
}
LCD_DrawLine(x0-r,y0,wide,Vertical);//(6,10,77,Vertical);
LCD_DrawLine(x0+r+Length,y0,wide,Vertical);//(192,10,77,Vertical);
LCD_DrawLine(x0,y0-r,Length,Horizontal);//(6,10,186,Horizontal);
LCD_DrawLine(x0,y0+wide+r,Length,Horizontal);//(6,87,186,Horizontal);
LCD_Fill(x0-r+1,y0,Length+2*r-1,wide,color);
}
复制代码
加载中...
查看其它22个回答
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
如何用FPGA驱动LCD屏?
5 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何改进LCD液晶屏的响应时间?
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
LCD
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
- /***********************************************************************************************************************
- * 函数名: LCD_DrawCircleRectangle
- * 参 数: x0 :X坐标
- * y0 :Y坐标
- * Length :长度
- * wide :方向(Horizontal,Vertical)
- * r :圆角半径
- * 返 回: 无
- * 功 能: 在LCD上画圆角矩形
- *************************************************************************************************************************/
- void LCD_DrawCircleRectangle(unsigned short x0,unsigned char y0,unsigned short Length,unsigned char wide,unsigned char r)
- {
- int a,b;
- int di;
- unsigned char QUA_Second_y0,QUA_Third_y0;
- unsigned short QUA_Third_x0,QUA_Four_x0;
-
- x0 = x0+r;
- y0 = y0+r;
- Length = Length-2*r;
- wide = wide-2*r;
- a=0;
- b=r;
- di=3-2*r;
- while(a<=b)
- {
- //第一象限
- LCD_DrawPoint(x0-a,y0-b); //2
- LCD_DrawPoint(x0-b,y0-a); //3
-
- //第二象限
- QUA_Second_y0 = y0+wide;
- LCD_DrawPoint(x0-a,QUA_Second_y0+b); //1
- LCD_DrawPoint(x0-b,QUA_Second_y0+a); //7
-
- //第三象限
- QUA_Third_y0 = y0+wide;
- QUA_Third_x0 = x0+Length;
- LCD_DrawPoint(QUA_Third_x0+a,QUA_Third_y0+b); //6
- LCD_DrawPoint(QUA_Third_x0+b,QUA_Third_y0+a); //4
-
- //第四象限
- QUA_Four_x0 = x0+Length;
- LCD_DrawPoint(QUA_Four_x0+a,y0-b); //5
- LCD_DrawPoint(QUA_Four_x0+b,y0-a); //0
-
- a++;
- if(di<0) di +=4*a+6;
- else
- {
- di+=10+4*(a-b);
- b--;
- }
- //LCD_DrawPoint(x0+a,y0+b);
- }
- LCD_DrawLine(x0-r,y0,wide,Vertical);//(6,10,77,Vertical);
- LCD_DrawLine(x0+r+Length,y0,wide,Vertical);//(192,10,77,Vertical);
- LCD_DrawLine(x0,y0-r,Length,Horizontal);//(6,10,186,Horizontal);
- LCD_DrawLine(x0,y0+wide+r,Length,Horizontal);//(6,87,186,Horizontal);
-
- }
- /***********************************************************************************************************************
- * 函数名: LCD_FillCircle
- * 参 数: x0 :X坐标
- * y0 :Y坐标
- * Length :长度
- * wide :方向(Horizontal,Vertical)
- * r :圆角半径
- * color :填充 {MOD}
- * 返 回: 无
- * 功 能: 用指定 {MOD}填充圆角矩形区域
- *************************************************************************************************************************/
- void LCD_FillCircle(unsigned short x0,unsigned char y0,unsigned short Length,unsigned char wide,unsigned char r,unsigned short color)
- {
- int a,b;
- int di;
- unsigned char QUA_Second_y0,QUA_Third_y0;
- unsigned short QUA_Third_x0,QUA_Four_x0;
-
- x0 = x0+r;
- y0 = y0+r;
- Length = Length-2*r;
- wide = wide-2*r;
- a=0;
- b=r;
- di=3-2*r;
- FontSet(3,color,1);
- while(a<=b)
- {
- //第一象限
- LCD_DrawPoint(x0-a,y0-b); //2
- LCD_DrawPoint(x0-b,y0-a); //3
-
- //第二象限
- QUA_Second_y0 = y0+wide;
- LCD_DrawPoint(x0-a,QUA_Second_y0+b); //1
- LCD_DrawPoint(x0-b,QUA_Second_y0+a); //7
-
- //第三象限
- QUA_Third_y0 = y0+wide;
- QUA_Third_x0 = x0+Length;
- LCD_DrawPoint(QUA_Third_x0+a,QUA_Third_y0+b); //6
- LCD_DrawPoint(QUA_Third_x0+b,QUA_Third_y0+a); //4
-
- //第四象限
- QUA_Four_x0 = x0+Length;
- LCD_DrawPoint(QUA_Four_x0+a,y0-b); //5
- LCD_DrawPoint(QUA_Four_x0+b,y0-a); //0
-
- LCD_DrawLine(x0-a,y0-b,(QUA_Four_x0+a)-(x0-a),Horizontal);
- LCD_DrawLine(x0-b,y0-a,(QUA_Four_x0+b)-(x0-b),Horizontal);
-
- LCD_DrawLine(x0-a,QUA_Second_y0+b,(QUA_Third_x0+a)-(x0-a),Horizontal);
- LCD_DrawLine(x0-b,QUA_Second_y0+a,(QUA_Four_x0+b)-(x0-b),Horizontal);
- a++;
- if(di<0) di +=4*a+6;
- else
- {
- di+=10+4*(a-b);
- b--;
- }
- }
- LCD_DrawLine(x0-r,y0,wide,Vertical);//(6,10,77,Vertical);
- LCD_DrawLine(x0+r+Length,y0,wide,Vertical);//(192,10,77,Vertical);
- LCD_DrawLine(x0,y0-r,Length,Horizontal);//(6,10,186,Horizontal);
- LCD_DrawLine(x0,y0+wide+r,Length,Horizontal);//(6,87,186,Horizontal);
-
- LCD_Fill(x0-r+1,y0,Length+2*r-1,wide,color);
- }
复制代码一周热门 更多>