ACLLib基本操作:Dev C++下
创建配置:
1,新建项目—>Windows application—>C项目–>输入项目名称
2,将acllib.c
和acllib.h
文件拷贝到创建的项目目录
3,菜单栏–>项目–>项目属性–>参数–>链接–>加入库文件,如下:(Dev C++具体目录以安装时为准)
- 32位下,库文件是:
“C:/Program Files/Dev-Cpp/MinGW32/lib/libwinmm.a”
“C:/Program Files/Dev-Cpp/MinGW32/lib/libmsimg32.a”
“C:/Program Files/Dev-Cpp/MinGW32/lib/libkernel32.a”
“C:/Program Files/Dev-Cpp/MinGW32/lib/libuser32.a”
“C:/Program Files/Dev-Cpp/MinGW32/lib/libgdi32.a”
“C:/Program Files/Dev-Cpp/MinGW32/lib/libole32.a”
“C:/Program Files/Dev-Cpp/MinGW32/lib/liboleaut32.a”
“C:/Program Files/Dev-Cpp/MinGW32/lib/libuuid.a”
- 64位下,库文件是:
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/libwinmm.a
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/libmsimg32.a
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/libkernel32.a
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/libuser32.a
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/libgdi32.a
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/libole32.a
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/liboleaut32.a
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib/libuuid.a
- 如果出现
“undefined reference to TransparentBlt ”
这个错误,两个解决方案:
- 打开acllib.c,找到“TransparentBlt”所在的行,把整行注释掉;
- 打开工程配置,找到编译器选项,加入-DWINVER=0x0500。
绘图函数:
1,创建窗口:
void initWindow(const char title[], int left, int top, int width, int height);
窗口位置参数left
和top
可以都设置为默认值:DEFAULT
,让系统自行调整位置。
2,启动和结束绘图:
画图内容要写在下面两个函数之间
void beginPaint();
void endPaint();
3,主函数:
int Setup()
{
return 0;
}
4,终端窗口:
如果需要用scanf
和printf
,则需要首先:
initConsole();
5,画点(像素点)
void putPixel(int x, int y, ACL_Color color);
ACL_Color getPixel(int x, int y)
6,颜色
RGB(r,g,b)
红色–>RGB(255,0,0)- 预设值:
BLACK,RED,GREEN,BLUE,CYAN,MAGENTA,YELLOW,WHITE
7,windows坐标轴从左上角(0,0)开始
x轴自左向右增长,y轴自上向下增长
8,线:
void moveTo(int x, int y);
void moveRel(int dx, int dy);
void line(int x0,int y0,int xl, int yl);
void lintTo(int x, int y);
void lineRel(int dx, int dy);
void arc(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXStartArc, int nYStartArc, int nXEndArc, int nYEndArc);
9,画笔:
void setPenColor(ACL_Color color);
void setPenWidth(int width);
void setPenStyle(ACL_Pen_Style style);
PEN_STYLE_SOLID,
PEN_STYLE_DASH, /* ------- */
PEN_STYLE_DOT, /* ......*/
PEN_STYLE_DASHDOT, /*-.-.-.-. */
PEN_STYLE_DASHDOTDOT, /*-..-..-.. */
PEN_STYLE_NULL
10,面:
void chrod(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int
nXRadial1, int nYRadial1, int nXRadial2, int nYRadial2);
void ellipse( int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
void pie(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int
nXRadial1, int nYRadial1, int nXRadial2, int nYRadial2);
void rectangle(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
void roundrect(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int
nWidth, int nHeight)
11,刷子:
画笔负责线及⾯的边缘,刷⼦负责⾯的内部
void setBrushColor(ACL_Color color);
void setBrushStyle(ACL_Brush_Style style);
• BRUSH_STYLE_SOLID = -1,
• BRUSH_STYLE_HORIZONTAL, /* ----- */
• BRUSH_STYLE_VERTICAL, /* ||||| */
• BRUSH_STYLE_FDIAGONAL, /* \\\\\ */
• BRUSH_STYLE_BDIAGONAL, /* / */
• BRUSH_STYLE_CROSS, /* +++++ */
• BRUSH_STYLE_DIAGCROSS, /* xxxxx */
12, 文字:
void setTextColor(ACL_Color color);
void setTextBkColor(ACL_Color color);
void setTextSize(int size);
void setTextFont(char *pFontName);
void paintText(int x, int y, const char *pStr);
The Callbacks(回调事件)
键盘:(普通按键,特殊功能键,按下和抬起两种状态)
typedef void(*KeyboardEventCallback)(const char key);
键盘上的可读字符:
typedef void(*CharEventCallback)(int key);
鼠标:(移动,按下和抬起)
typedef void(*MouseEventCallback)(int x, int y, int button, int status);
定时器:
typedef void(*TimerEventCallback)(int timerID);
MVC设计模式
View <-- Model <-- Ctrl
- View :
读数据,放入mod;
显示时,从model取数据
- Mod:
存储数据;修改后会通知View
- Ctrl:
告诉Model数据怎么改