Release 990226.
[wine/gsoc-2012-control.git] / objects / linedda.c
blobe3de9446c21d07cb2fabbba8712e53289bf0e209
1 /*
2 * LineDDA
4 * Copyright 1993 Bob Amstadt
5 */
7 #include <stdlib.h>
8 #include "wingdi.h"
11 /**********************************************************************
12 * LineDDA16 (GDI.100)
14 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd, INT16 nYEnd,
15 LINEDDAPROC16 callback, LPARAM lParam )
17 LineDDA( nXStart, nYStart, nXEnd, nYEnd,
18 (LINEDDAPROC)callback, lParam );
22 /**********************************************************************
23 * LineDDA32 (GDI32.248)
25 BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd,
26 LINEDDAPROC callback, LPARAM lParam )
28 INT xadd = 1, yadd = 1;
29 INT err,erradd;
30 INT cnt;
31 INT dx = nXEnd - nXStart;
32 INT 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;