Skip to content
Newer
Older
100755 87 lines (71 sloc) 2.94 KB
6a767a7 @uliwitness Big clean-up. Adopted new prefix. Fixed support for line and fill col…
authored May 1, 2011
1 //
2 // UlisBresenham.h
3 // Mediator 4
4 //
5 // Created by Uli Kusterer on 2001-12-25
6 // Copyright (c) 2001 Uli Kusterer.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
26 //
27
28 /*
29 Utility routine that allows computing lines. E.g. to draw shapes that are
30 on a line, hit-testing on a line or whatever.
31 */
a516cc8 Initial check-in.
uli authored Jul 4, 2009
32
33 #ifndef ULIS_BRESENHAM_H
34 #define ULIS_BRESENHAM_H
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40
41 /* -----------------------------------------------------------------------------
42 Data types:
43 This is the kind of callback procedure you pass to DrawBresenhamLine.
44 Each point of the line will be passed to this function (in order).
45 Provide such a function that does whatever you want with the points.
46 It could record them in an array, it could draw a brush shape across
47 the line, it could even just call SetPixel() to draw the pixel.
48
49 userData is the data you pass into DrawBresenhamLine(). Use this to
50 e.g. pass in the GrafPort you're drawing to, or a C++ object with
51 additional data, or whatever.
52 -------------------------------------------------------------------------- */
53
54 typedef void (*BresenhamPixelProcPtr)( float h, float v, void* userData );
55
56
57 /* -----------------------------------------------------------------------------
58 DrawBresenhamLine:
59 Computes a line from startX,startY to endX,endY, passing the
60 coordinates to the function specified.
61
62 TAKES:
63 startX - Horizontal coordinate of starting point.
64 startY - Vertical coordinate of starting point.
65 endX - Horz. coord. of end pt.
66 endY - Vert. coord. of end pt.
67 pixelDrawProc - Function of type
68 void name( float h, float v, void* userData )
69 that will be called for each pixel to do something
70 with it, e.g. draw it.
71 userData - Any data you wish that will be passed on to your
72 pixeldrawProc as a service (i.e. it's a refCon).
73
74 REVISIONS:
75 2001-12-25 UK Created.
76 -------------------------------------------------------------------------- */
77
78 void DrawBresenhamLine( float startX, float startY, float endX, float endY,
79 BresenhamPixelProcPtr pixelDrawProc, void* userData );
80
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86
87 #endif /*ULIS_BRESENHAM_H*/
Something went wrong with that request. Please try again.