----------------------------------------------------------------------
// main.c
// Created by weichen on 15/7/7.
// Copyright (c) 2015年 weichen. All rights reserved.
#include <stdio.h>
int main(int argc, const char * argv[]) {
/*
Windows API:
從第一個32位的Windows開始就出現了,就叫做Win32API.
它是一個純C的函數庫,就和C標准庫一樣,使你可以寫Windows應用程序
過去很多Windows程序是用這個方式做出來的
main():
main()成為C語言的入口函數其實和C語言本身無關,你的代碼是被一小段叫做啟動代碼的程序所調用的,它需要一個叫做main的地方
操作系統把你的可執行程序裝載到內存裡,啟動運行,然後調用你的main函數
WinMain():
As main() is the entry function of an ordinary C program, WinMain() is the one Win32API program.
Windows applications have a different "startup" code that needs a function "WinMain()".
#include <windows.h>
int WINAPI WinMain(
HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) //參數
{
MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
return 0;
}
// 創建ACLlib程序
#include "acllib.h"
#include <stdio.h>
int Setup()
{
initConsole();
printf("輸入寬度:");
int width;
scanf("%d", &width);
initWindow("test", 100, 100, width, width);
beginPaint();
line(20, 20, width - 20, width - 20);
putPixel(100,150,RGB(255,255,0));
endPaint();
return 0;
// 基本繪圖函數
創建圖形窗口
void initWindow(const char title[], int left, int top, int width, int height);
坐標系
在windows/unix中,坐標是以像素點得數字來定義的。對於你創建出來的窗口,左上角是(0,0), x軸自左向右增長,而y軸自上向下增長
終端窗口
如果需要用scanf和printf, 則需要首先initConsole();
然後就可以在那個窗口上使用scanf和printf了
啟動/結束繪圖
void beginPaint();
void endPaint();
任何繪圖函數的調用必須在這一對函數調用之間
點
void putPixel(int x, int y, ACL_Color color);
ACL_Color getPixel(int x, int y);
顏色
RGB(r,g,b);
紅色 -> RGB(255,0,0);
BLACK,RED,GREEN,BLUE,CYAN,MAGENTA,YELLOW,WHITE
線
void moveTo(int x, int y);
void moveRel(int dx, int dy);
void line(int x0, int y0, int x1, int y1);
void lineTo(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);
畫筆
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,
面
void chrod();
void ellipse();
void pie();
void rectangle();
void roundrect();
刷子
畫筆負責線及面的邊緣,刷子負責面的內部
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, // xxxx
文字
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);
*/
printf("Hello, World!\n");
return 0;
}
ACLLib在github上開源,網址是:https://github.com/wengkai/ACLLib
使用Windows下的多種IDE都可以使用ACLLib,包括但不限於DevC++、MS Visual Studio、CodeBlocks等,也可以直接由MinGW編譯器以Makefile方式編譯。
Link:http://www.cnblogs.com/farwish/p/4628568.html
@黑眼詩人 <www.farwish.com>