LineDDA,是計算機函式語言。
基本介紹
- 中文名:LineDDA
- 外文名:LineDDA
- Parameters:nXStart
- lpLineFunc:nYEnd
簡介,聲明,
簡介
LineDDA
The LineDDA function determines which pixels should be highlighted for a line defined by the specified starting and ending points.
BOOL LineDDA(
int nXStart, // x-coordinate of starting point
int nYStart, // y-coordinate of starting point
int nXEnd, // x-coordinate of ending point
int nYEnd, // y-coordinate of ending point
LINEDDAPROC lpLineFunc, // callback function
LPARAM lpData // application-defined data
);
Parameters
nXStart
[in] Specifies the x-coordinate, in logical units, of the line's starting point.
nYStart
[in] Specifies the y-coordinate, in logical units, of the line's starting point.
nXEnd
[in] Specifies the x-coordinate, in logical units, of the line's ending point.
nYEnd
[in] Specifies the y-coordinate, in logical units, of the line's ending point.
lpLineFunc
[in] Pointer to an application-defined callback function. For more information, see the LineDDAProc callback function.
lpData
[in] Pointer to the application-defined data.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT/2000/XP: To get extended error information, call GetLastError.
Remarks
The LineDDA function passes the coordinates for each point along the line, except for the line's ending point, to the application-defined callback function. In addition to passing the coordinates of a point, this function passes any existing application-defined data.
The coordinates passed to the callback function match pixels on a video display only if the default transformations and mapping modes are used.
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.
如果在VC中實現比較簡單的動畫效果,也許很多人會選用Timer控制項,其實API函式中有一個LineDDA,用這個函式實現簡單的動畫效果還是比較不錯的。因為是API函式,所以很一般化,因此很多語言都可以用它來實現簡單的動畫。
該函式的原型如下:
BOOL LineDDA(int nXStart, int nYStart, int nXEnd, int nYEnd, LINEDDAPROC lpLineFunc, LPARAM lpData);
參數說明如下:
nXStart:起點的X值
nYStart:起點的Y值
nXEnd:終點的X值
nYEnd:終點的Y值
lpLineFunc:回調函式的地址
lpData:用戶自定義參數(這個參數會傳給回調函式)
這個函式和動畫其實沒什麼關係,它的功能就是計算出連線兩點的線段上的每一個螢幕像素的坐標,這兩個點的坐標已經在函式的前四個參數中給出。每計算出一個坐標,該函式就會調用第五個參數所指的回調函式,我們可以在回調函式中完成一些簡單的操作,以實現動畫效果。
回調函式的原型是: VOID CALLBACK LineDDAProc(int X, int Y, LPARAM lpData);
前兩個參數是點的坐標,第三個參數就是由LineDDA傳過來的自定義參數,是由我們自己指定的,傳什麼都行。 :)
聲明
LineDDA 函式在VB中的是:
Public Declare Function LineDDA Lib "gdi32.dll" (ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal lpLineDDAProc As Long, ByVal lParam As Long) As Long
其回調用函式原型為:
Public Sub LineDDAProc(ByVal X As Long, ByVal Y As Long, ByVal lpData As Long)