Update LineDDA implementation, -13 gdi32 path tests
[reactos.git] / reactos / dll / win32 / gdi32 / objects / linedda.c
1 /*
2 * GDI drawing functions.
3 *
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
6 * 1999 Huw D M Davies
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22 /*
23 * COPYRIGHT: See COPYING in the top level directory
24 * PROJECT: ReactOS GDI32
25 * PURPOSE: LineDDA Function
26 * FILE: dll/win32/gdi32/objects/linedda.c
27 * PROGRAMER: Steven Edwards
28 * REVISION HISTORY: 2003/11/15 sedwards Created, 2009/04 gschneider Updated
29 * NOTES: Adapted from Wine
30 */
31
32 #include "precomp.h"
33
34 #include <debug.h>
35
36 /**********************************************************************
37 * LineDDA (GDI32.@)
38 * @implemented
39 */
40 BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd,
41 LINEDDAPROC callback, LPARAM lParam )
42 {
43 INT xadd = 1, yadd = 1;
44 INT err,erradd;
45 INT cnt;
46 INT dx = nXEnd - nXStart;
47 INT dy = nYEnd - nYStart;
48
49 if (dx < 0)
50 {
51 dx = -dx;
52 xadd = -1;
53 }
54 if (dy < 0)
55 {
56 dy = -dy;
57 yadd = -1;
58 }
59 if (dx > dy) /* line is "more horizontal" */
60 {
61 err = 2*dy - dx; erradd = 2*dy - 2*dx;
62 for(cnt = 0;cnt < dx; cnt++)
63 {
64 callback(nXStart,nYStart,lParam);
65 if (err > 0)
66 {
67 nYStart += yadd;
68 err += erradd;
69 }
70 else err += 2*dy;
71 nXStart += xadd;
72 }
73 }
74 else /* line is "more vertical" */
75 {
76 err = 2*dx - dy; erradd = 2*dx - 2*dy;
77 for(cnt = 0;cnt < dy; cnt++)
78 {
79 callback(nXStart,nYStart,lParam);
80 if (err > 0)
81 {
82 nXStart += xadd;
83 err += erradd;
84 }
85 else err += 2*dx;
86 nYStart += yadd;
87 }
88 }
89 return TRUE;
90 }
91