Added Makefile.
[wine.git] / objects / linedda.c
blob7297860366dee8b7cf586b76e8adf566a3fcea07
1 /*
2 * LineDDA
4 * Copyright 1993 Bob Amstadt
5 */
7 #include <stdlib.h>
8 #include "windows.h"
11 /**********************************************************************
12 * LineDDA16 (GDI.100)
14 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd, INT16 nYEnd,
15 LINEDDAPROC16 callback, LPARAM lParam )
17 LineDDA32( nXStart, nYStart, nXEnd, nYEnd,
18 (LINEDDAPROC32)callback, lParam );
22 /**********************************************************************
23 * LineDDA32 (GDI32.248)
25 BOOL32 WINAPI LineDDA32(INT32 nXStart, INT32 nYStart, INT32 nXEnd, INT32 nYEnd,
26 LINEDDAPROC32 callback, LPARAM lParam )
28 INT32 xadd = 1, yadd = 1;
29 INT32 err,erradd;
30 INT32 cnt;
31 INT32 dx = nXEnd - nXStart;
32 INT32 dy = nYEnd - nYStart;
34 if (dx < 0) {
35 dx = -dx; xadd = -1;
37 if (dy < 0) {
38 dy = -dy; yadd = -1;
40 if (dx > dy) { /* line is "more horizontal" */
41 err = 2*dy - dx; erradd = 2*dy - 2*dx;
42 for(cnt = 0;cnt <= dx; cnt++) {
43 callback(nXStart,nYStart,lParam);
44 if (err > 0) {
45 nYStart += yadd;
46 err += erradd;
47 } else {
48 err += 2*dy;
50 nXStart += xadd;
52 } else { /* line is "more vertical" */
53 err = 2*dx - dy; erradd = 2*dx - 2*dy;
54 for(cnt = 0;cnt <= dy; cnt++) {
55 callback(nXStart,nYStart,lParam);
56 if (err > 0) {
57 nXStart += xadd;
58 err += erradd;
59 } else {
60 err += 2*dx;
62 nYStart += yadd;
65 return TRUE;