硬汉嵌入式论坛

 找回密码
 立即注册
查看: 6012|回复: 2
收起左侧

[有问必答] 指针旋转问题

[复制链接]

29

主题

39

回帖

29

积分

初级会员

积分
29
发表于 2016-3-17 10:07:51 | 显示全部楼层 |阅读模式
在60期教程中,介绍了一个抗锯齿的旋转指针例子,我没有用抗锯齿。结合前面绘制弧线的例子,做一个旋转表盘。中间用背景色清除一块矩形区,我改成了用圆形区填充。但是结果出现了一个不明白的现象。如图,中间好像一直有一个绘制矩形区,在程序中没看到啊? 1.png 2.png
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117546
QQ
发表于 2016-3-17 12:05:58 | 显示全部楼层
单看你贴的代码没有看出什么问题,参看我做的那个表盘界面设计
https://forum.anfulai.cn/forum.php?mod=viewthread&tid=5598
回复

使用道具 举报

29

主题

39

回帖

29

积分

初级会员

积分
29
 楼主| 发表于 2016-3-17 12:34:33 | 显示全部楼层

回 eric2013 的帖子

eric2013:单看你贴的代码没有看出什么问题,参看我做的那个表盘界面设计
https://forum.anfulai.cn/forum.php?mod=viewthread&tid=5598 (2016-03-17 12:05)
#include "GUI.h"
#include "math.h"
#include "stdio.h"

#define countof(Array) (sizeof(Array)/sizeof(Array[0]))

static GUI_POINT _aPointer[] = {
    { 0, 3},
    {85, 1},
    {90, 0},
    {85, -1},
    { 0, -3}
};

typedef struct {
    GUI_AUTODEV_INFO AutoInfo;
    GUI_POINT aPoints[countof(_aPointer)];
}PARAM;

static void _Draw(void * p) {
    PARAM * pParam = (PARAM *)p;
    if (pParam->AutoInfo.DrawFixed) {
        //GUI_ClearRect(60, 60, 259, 159);
        GUI_SetColor(GUI_BLACK);
        GUI_FillCircle(165,155,92);
    }
    GUI_SetColor(GUI_WHITE);
    GUI_AA_FillPolygon(pParam->aPoints, countof(_aPointer), 165, 155);
}

static void _ShowHiresAntialiasing(){
    GUI_AUTODEV aAuto;
    PARAM Param;
    int i = 0;
    int x0 = 165;
    int y0 = 155;
    char ac[4];

    GUI_SetBkColor(GUI_BLACK);
    GUI_Clear();
    GUI_SetColor(GUI_WHITE);

    GUI_SetPenSize(4);
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_SetFont(&GUI_FontComic18B_ASCII);
    GUI_DrawArc( x0,y0,135, 135, 0, 180);
    GUI_Delay(10);
    for(i = 0;i<19;i++){
        float a = i*10*3.1415926/180;
        int x = -125*cos(a) + x0;
        int y = -125*sin(a) + y0;
        if(i%2 == 0)
            GUI_SetPenSize(5);
        else
            GUI_SetPenSize(4);
        GUI_DrawPoint(x,y);
        if(i%2 == 0){
            x = -100*cos(a) + x0;
            y = -110*sin(a) + y0;
            sprintf(ac, "%d", i*10);
            GUI_SetTextAlign(GUI_TA_VCENTER);
            GUI_DispStringHCenterAt(ac, x, y);
        }
    }

    GUI_MEMDEV_CreateAuto(&aAuto);

    while(1) {
        for (i = 0; i < 180; i++) {
            float Angle = i;
            Angle *= 3.1415926f / 180;
            GUI_RotatePolygon(Param.aPoints, _aPointer, countof(_aPointer), Angle);
            GUI_MEMDEV_DrawAuto(&aAuto, &amparam.AutoInfo, _Draw, &amparam);
            GUI_Delay(50);
        }
    }
}

void MainTask(void) {
    GUI_Init();
    _ShowHiresAntialiasing();
    while(1) {
        GUI_Delay(100);
    }
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-14 01:17 , Processed in 0.039829 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表