1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_slideshow.hxx"
26
27 #include <canvas/debug.hxx>
28 #include <basegfx/numeric/ftools.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <basegfx/point/b2dpoint.hxx>
31 #include <basegfx/matrix/b2dhommatrixtools.hxx>
32 #include "transitiontools.hxx"
33 #include "figurewipe.hxx"
34
35
36 namespace slideshow {
37 namespace internal {
38
operator ()(double t)39 ::basegfx::B2DPolyPolygon FigureWipe::operator () ( double t )
40 {
41 ::basegfx::B2DPolyPolygon res(m_figure);
42 res.transform(basegfx::tools::createScaleTranslateB2DHomMatrix(t, t, 0.5, 0.5));
43 return res;
44 }
45
createTriangleWipe()46 FigureWipe * FigureWipe::createTriangleWipe()
47 {
48 const double s60 = sin( basegfx::deg2rad(60.0) );
49 const double s30 = sin( basegfx::deg2rad(30.0) );
50 ::basegfx::B2DPolygon figure;
51 figure.append( ::basegfx::B2DPoint( 0.5 + s30, 0.5 ) );
52 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
53 figure.append( ::basegfx::B2DPoint( -0.5 - s30, 0.5 ) );
54 figure.setClosed(true);
55 return new FigureWipe(figure);
56 }
57
createArrowHeadWipe()58 FigureWipe * FigureWipe::createArrowHeadWipe()
59 {
60 const double s60 = sin( basegfx::deg2rad(60.0) );
61 const double s30 = sin( basegfx::deg2rad(30.0) );
62 const double off = s30;
63 ::basegfx::B2DPolygon figure;
64 figure.append( ::basegfx::B2DPoint( 0.5 + s30 + off, 0.5 + off ) );
65 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
66 figure.append( ::basegfx::B2DPoint( -0.5 - s30 - off, 0.5 + off ) );
67 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 ) );
68 figure.setClosed(true);
69 return new FigureWipe(figure);
70 }
71
createPentagonWipe()72 FigureWipe * FigureWipe::createPentagonWipe()
73 {
74 const double s = sin( basegfx::deg2rad(18.0) );
75 const double c = cos( basegfx::deg2rad(18.0) );
76 ::basegfx::B2DPolygon figure;
77 figure.append( ::basegfx::B2DPoint( 0.5, 0.5 ) );
78 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.5 - c ) );
79 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 - c - sin(basegfx::deg2rad(36.0)) ) );
80 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.5 - c ) );
81 figure.append( ::basegfx::B2DPoint( -0.5, 0.5 ) );
82 figure.setClosed(true);
83 return new FigureWipe(figure);
84 }
85
createHexagonWipe()86 FigureWipe * FigureWipe::createHexagonWipe()
87 {
88 const double s = sin( basegfx::deg2rad(30.0) );
89 const double c = cos( basegfx::deg2rad(30.0) );
90 ::basegfx::B2DPolygon figure;
91 figure.append( ::basegfx::B2DPoint( 0.5, c ) );
92 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.0 ) );
93 figure.append( ::basegfx::B2DPoint( 0.5, -c ) );
94 figure.append( ::basegfx::B2DPoint( -0.5, -c ) );
95 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.0 ) );
96 figure.append( ::basegfx::B2DPoint( -0.5, c ) );
97 figure.setClosed(true);
98 return new FigureWipe(figure);
99 }
100
createStarWipe(sal_Int32 nPoints)101 FigureWipe * FigureWipe::createStarWipe( sal_Int32 nPoints )
102 {
103 const double v = (M_PI / nPoints);
104 const ::basegfx::B2DPoint p_( 0.0, -M_SQRT2 );
105 ::basegfx::B2DPolygon figure;
106 for ( sal_Int32 pos = 0; pos < nPoints; ++pos ) {
107 const double w = (pos * 2.0 * M_PI / nPoints);
108 ::basegfx::B2DHomMatrix aTransform;
109 ::basegfx::B2DPoint p(p_);
110 aTransform.rotate( -w );
111 p *= aTransform;
112 figure.append(p);
113 p = p_;
114 aTransform.identity();
115 aTransform.scale( 0.5, 0.5 );
116 aTransform.rotate( -w - v );
117 p *= aTransform;
118 figure.append(p);
119 }
120 figure.setClosed(true);
121 return new FigureWipe(figure);
122 }
123
124 }
125 }
126