ReactOS 0.4.15-dev-5672-gf73ac17
linedda.c
Go to the documentation of this file.
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: win32ss/gdi/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 */
40BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd,
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;
62 erradd = 2*dy - 2*dx;
63 for(cnt = 0; cnt < dx; cnt++)
64 {
65 callback(nXStart,nYStart,lParam);
66 if (err > 0)
67 {
68 nYStart += yadd;
69 err += erradd;
70 }
71 else err += 2*dy;
72 nXStart += xadd;
73 }
74 }
75 else /* line is "more vertical" */
76 {
77 err = 2*dx - dy;
78 erradd = 2*dx - 2*dy;
79 for(cnt = 0; cnt < dy; cnt++)
80 {
81 callback(nXStart,nYStart,lParam);
82 if (err > 0)
83 {
84 nXStart += xadd;
85 err += erradd;
86 }
87 else err += 2*dx;
88 nYStart += yadd;
89 }
90 }
91 return TRUE;
92}
93
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd, LINEDDAPROC callback, LPARAM lParam)
Definition: linedda.c:40
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
static IPrintDialogCallback callback
Definition: printdlg.c:326
#define err(...)
int32_t INT
Definition: typedefs.h:58
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
FARPROC LINEDDAPROC
Definition: wingdi.h:2906