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/matrix/b2dhommatrix.hxx>
29 #include <basegfx/point/b2dpoint.hxx>
30 #include <basegfx/numeric/ftools.hxx>
31 #include <basegfx/matrix/b2dhommatrixtools.hxx>
32 #include "transitiontools.hxx"
33 #include "zigzagwipe.hxx"
34 
35 
36 namespace slideshow {
37 namespace internal {
38 
ZigZagWipe(sal_Int32 nZigs)39 ZigZagWipe::ZigZagWipe( sal_Int32 nZigs ) : m_zigEdge( 1.0 / nZigs )
40 {
41     const double d = m_zigEdge;
42     const double d2 = (d / 2.0);
43     m_stdZigZag.append( ::basegfx::B2DPoint( -1.0 - d, -d ) );
44     m_stdZigZag.append( ::basegfx::B2DPoint( -1.0 - d, 1.0 + d ) );
45     m_stdZigZag.append( ::basegfx::B2DPoint( -d, 1.0 + d ) );
46     for ( sal_Int32 pos = (nZigs + 2); pos--; ) {
47         m_stdZigZag.append( ::basegfx::B2DPoint( 0.0, ((pos - 1) * d) + d2 ) );
48         m_stdZigZag.append( ::basegfx::B2DPoint( -d, (pos - 1) * d ) );
49     }
50     m_stdZigZag.setClosed(true);
51 }
52 
operator ()(double t)53 ::basegfx::B2DPolyPolygon ZigZagWipe::operator () ( double t )
54 {
55     ::basegfx::B2DPolyPolygon res(m_stdZigZag);
56     res.transform(basegfx::tools::createTranslateB2DHomMatrix((1.0 + m_zigEdge) * t, 0.0));
57     return res;
58 }
59 
operator ()(double t)60 ::basegfx::B2DPolyPolygon BarnZigZagWipe::operator () ( double t )
61 {
62     ::basegfx::B2DPolyPolygon res( createUnitRect() );
63     ::basegfx::B2DPolygon poly( m_stdZigZag );
64     poly.flip();
65     basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(
66         (1.0 + m_zigEdge) * (1.0 - t) / 2.0, 0.0));
67     poly.transform( aTransform );
68     res.append( poly );
69     aTransform.scale( -1.0, 1.0 );
70     aTransform.translate( 1.0, m_zigEdge / 2.0 );
71     poly = m_stdZigZag;
72     poly.transform( aTransform );
73     res.append( poly );
74     return res;
75 }
76 
77 }
78 }
79