Update ooo320-m1
[ooovba.git] / slideshow / source / engine / transitions / figurewipe.cxx
blobaccc4a8886ddfa9f2066865e53fe4cc8836493bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: figurewipe.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 * ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
34 #include <canvas/debug.hxx>
35 #include <basegfx/numeric/ftools.hxx>
36 #include <basegfx/matrix/b2dhommatrix.hxx>
37 #include <basegfx/point/b2dpoint.hxx>
38 #include "transitiontools.hxx"
39 #include "figurewipe.hxx"
42 namespace slideshow {
43 namespace internal {
45 ::basegfx::B2DPolyPolygon FigureWipe::operator () ( double t )
47 ::basegfx::B2DPolyPolygon res(m_figure);
48 ::basegfx::B2DHomMatrix aTransform;
49 aTransform.scale( t, t );
50 aTransform.translate( 0.5, 0.5 );
51 res.transform( aTransform );
52 return res;
55 FigureWipe * FigureWipe::createTriangleWipe()
57 const double s60 = sin( basegfx::deg2rad(60.0) );
58 const double s30 = sin( basegfx::deg2rad(30.0) );
59 ::basegfx::B2DPolygon figure;
60 figure.append( ::basegfx::B2DPoint( 0.5 + s30, 0.5 ) );
61 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
62 figure.append( ::basegfx::B2DPoint( -0.5 - s30, 0.5 ) );
63 figure.setClosed(true);
64 return new FigureWipe(figure);
67 FigureWipe * FigureWipe::createArrowHeadWipe()
69 const double s60 = sin( basegfx::deg2rad(60.0) );
70 const double s30 = sin( basegfx::deg2rad(30.0) );
71 const double off = s30;
72 ::basegfx::B2DPolygon figure;
73 figure.append( ::basegfx::B2DPoint( 0.5 + s30 + off, 0.5 + off ) );
74 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
75 figure.append( ::basegfx::B2DPoint( -0.5 - s30 - off, 0.5 + off ) );
76 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 ) );
77 figure.setClosed(true);
78 return new FigureWipe(figure);
81 FigureWipe * FigureWipe::createPentagonWipe()
83 const double s = sin( basegfx::deg2rad(18.0) );
84 const double c = cos( basegfx::deg2rad(18.0) );
85 ::basegfx::B2DPolygon figure;
86 figure.append( ::basegfx::B2DPoint( 0.5, 0.5 ) );
87 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.5 - c ) );
88 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 - c - sin(basegfx::deg2rad(36.0)) ) );
89 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.5 - c ) );
90 figure.append( ::basegfx::B2DPoint( -0.5, 0.5 ) );
91 figure.setClosed(true);
92 return new FigureWipe(figure);
95 FigureWipe * FigureWipe::createHexagonWipe()
97 const double s = sin( basegfx::deg2rad(30.0) );
98 const double c = cos( basegfx::deg2rad(30.0) );
99 ::basegfx::B2DPolygon figure;
100 figure.append( ::basegfx::B2DPoint( 0.5, c ) );
101 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.0 ) );
102 figure.append( ::basegfx::B2DPoint( 0.5, -c ) );
103 figure.append( ::basegfx::B2DPoint( -0.5, -c ) );
104 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.0 ) );
105 figure.append( ::basegfx::B2DPoint( -0.5, c ) );
106 figure.setClosed(true);
107 return new FigureWipe(figure);
110 FigureWipe * FigureWipe::createStarWipe( sal_Int32 nPoints )
112 const double v = (M_PI / nPoints);
113 const ::basegfx::B2DPoint p_( 0.0, -M_SQRT2 );
114 ::basegfx::B2DPolygon figure;
115 for ( sal_Int32 pos = 0; pos < nPoints; ++pos ) {
116 const double w = (pos * 2.0 * M_PI / nPoints);
117 ::basegfx::B2DHomMatrix aTransform;
118 ::basegfx::B2DPoint p(p_);
119 aTransform.rotate( -w );
120 p *= aTransform;
121 figure.append(p);
122 p = p_;
123 aTransform.identity();
124 aTransform.scale( 0.5, 0.5 );
125 aTransform.rotate( -w - v );
126 p *= aTransform;
127 figure.append(p);
129 figure.setClosed(true);
130 return new FigureWipe(figure);