1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

/* * Mode: C++; tabwidth: 4; indenttabsmode: nil; cbasicoffset: 4 * */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org  a multiplatform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _BGFX_TOOLS_TOOLS_HXX
#define _BGFX_TOOLS_TOOLS_HXX
#include <sal/types.h>
#include <basegfx/basegfxdllapi.h>
namespace basegfx
{
class B2DPoint;
class B2DRange;
namespace tools
{
/** LiangBarsky 2D line clipping algorithm
This function clips a line given by two points against the
given rectangle. The resulting line is returned in the
given points.
@param io_rStart
Start point of the line. On return, contains the clipped
start point.
@param io_rEnd
End point of the line. On return, contains the clipped
end point.
@param rClipRect
The rectangle to clip against
@return true, when at least part of the line is visible
after the clip, false otherwise
*/
BASEGFX_DLLPUBLIC bool liangBarskyClip2D( ::basegfx::B2DPoint& io_rStart,
::basegfx::B2DPoint& io_rEnd,
const ::basegfx::B2DRange& rClipRect );
/** Expand given parallelogram, such that it extends beyond
bound rect in a given direction.
This method is useful when e.g. generating onedimensional
gradients, such as linear or axial gradients: those
gradients vary only in one direction, the other has
constant color. Most of the time, those gradients extends
infinitely in the direction with the constant color, but
practically, one always has a limiting bound rect into
which the gradient is painted. The method at hand now
extends a given parallelogram (e.g. the transformed
bounding box of a gradient) virtually into infinity to the
top and to the bottom (i.e. normal to the line io_rLeftTop
io_rRightTop), such that the given rectangle is guaranteed
to be covered in that direction.
@attention There might be some peculiarities with this
method, that might limit its usage to the described
gradients. One of them is the fact that when determining
how far the parallelogram has to be extended to the top or
the bottom, the upper and lower border are assumed to be
infinite lines.
@param io_rLeftTop
Left, top edge of the parallelogramm. Note that this need
not be the left, top edge geometrically, it's just used
when determining the extension direction. Thus, it's
perfectly legal to affinetransform a rectangle, and given
the transformed point here. On method return, this
parameter will contain the adapted output.
@param io_rLeftBottom
Left, bottom edge of the parallelogramm. Note that this need
not be the left, bottom edge geometrically, it's just used
when determining the extension direction. Thus, it's
perfectly legal to affinetransform a rectangle, and given
the transformed point here. On method return, this
parameter will contain the adapted output.
@param io_rRightTop
Right, top edge of the parallelogramm. Note that this need
not be the right, top edge geometrically, it's just used
when determining the extension direction. Thus, it's
perfectly legal to affinetransform a rectangle, and given
the transformed point here. On method return, this
parameter will contain the adapted output.
@param io_rRightBottom
Right, bottom edge of the parallelogramm. Note that this need
not be the right, bottom edge geometrically, it's just used
when determining the extension direction. Thus, it's
perfectly legal to affinetransform a rectangle, and given
the transformed point here. On method return, this
parameter will contain the adapted output.
@param rFitTarget
The rectangle to fit the parallelogram into.
*/
BASEGFX_DLLPUBLIC void infiniteLineFromParallelogram( ::basegfx::B2DPoint& io_rLeftTop,
::basegfx::B2DPoint& io_rLeftBottom,
::basegfx::B2DPoint& io_rRightTop,
::basegfx::B2DPoint& io_rRightBottom,
const ::basegfx::B2DRange& rFitTarget );
}
}
#endif /* _BGFX_TOOLS_TOOLS_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
