More general approach to file descriptor types and flags.
[wine.git] / objects / linedda.c
blobf02531677f8211030d394d2e9b3bfc3e58b3dcf8
1 /*
2 * LineDDA
4 * Copyright 1993 Bob Amstadt
5 */
7 #include <stdlib.h>
8 #include "windef.h"
9 #include "wingdi.h"
10 #include "wine/wingdi16.h"
12 /* ### start build ### */
13 extern WORD CALLBACK DDA_CallTo16_word_wwl(LINEDDAPROC16,WORD,WORD,LONG);
14 /* ### stop build ### */
16 struct linedda16_info
18 LINEDDAPROC16 proc;
19 LPARAM param;
23 static void CALLBACK DDA_callback( INT x, INT y, LPARAM param )
25 const struct linedda16_info *info = (struct linedda16_info *)param;
26 DDA_CallTo16_word_wwl( info->proc, x, y, info->param );
29 /**********************************************************************
30 * LineDDA (GDI32.@)
32 BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd,
33 LINEDDAPROC callback, LPARAM lParam )
35 INT xadd = 1, yadd = 1;
36 INT err,erradd;
37 INT cnt;
38 INT dx = nXEnd - nXStart;
39 INT dy = nYEnd - nYStart;
41 if (dx < 0) {
42 dx = -dx; xadd = -1;
44 if (dy < 0) {
45 dy = -dy; yadd = -1;
47 if (dx > dy) { /* line is "more horizontal" */
48 err = 2*dy - dx; erradd = 2*dy - 2*dx;
49 for(cnt = 0;cnt <= dx; cnt++) {
50 callback(nXStart,nYStart,lParam);
51 if (err > 0) {
52 nYStart += yadd;
53 err += erradd;
54 } else {
55 err += 2*dy;
57 nXStart += xadd;
59 } else { /* line is "more vertical" */
60 err = 2*dx - dy; erradd = 2*dx - 2*dy;
61 for(cnt = 0;cnt <= dy; cnt++) {
62 callback(nXStart,nYStart,lParam);
63 if (err > 0) {
64 nXStart += xadd;
65 err += erradd;
66 } else {
67 err += 2*dx;
69 nYStart += yadd;
72 return TRUE;
76 /**********************************************************************
77 * LineDDA (GDI.100)
79 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
80 INT16 nYEnd, LINEDDAPROC16 proc, LPARAM lParam )
82 struct linedda16_info info;
83 info.proc = proc;
84 info.param = lParam;
85 LineDDA( nXStart, nYStart, nXEnd, nYEnd, DDA_callback, (LPARAM)&info );