1*70f497fbSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*70f497fbSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*70f497fbSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*70f497fbSAndrew Rist  * distributed with this work for additional information
6*70f497fbSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*70f497fbSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*70f497fbSAndrew Rist  * "License"); you may not use this file except in compliance
9*70f497fbSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*70f497fbSAndrew Rist  *
11*70f497fbSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*70f497fbSAndrew Rist  *
13*70f497fbSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*70f497fbSAndrew Rist  * software distributed under the License is distributed on an
15*70f497fbSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*70f497fbSAndrew Rist  * KIND, either express or implied.  See the License for the
17*70f497fbSAndrew Rist  * specific language governing permissions and limitations
18*70f497fbSAndrew Rist  * under the License.
19*70f497fbSAndrew Rist  *
20*70f497fbSAndrew Rist  *************************************************************/
21*70f497fbSAndrew Rist 
22*70f497fbSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_slideshow.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <canvas/debug.hxx>
28cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
29cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
30cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
31cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
32cdf0e10cSrcweir #include "transitiontools.hxx"
33cdf0e10cSrcweir #include "zigzagwipe.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace slideshow {
37cdf0e10cSrcweir namespace internal {
38cdf0e10cSrcweir 
ZigZagWipe(sal_Int32 nZigs)39cdf0e10cSrcweir ZigZagWipe::ZigZagWipe( sal_Int32 nZigs ) : m_zigEdge( 1.0 / nZigs )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     const double d = m_zigEdge;
42cdf0e10cSrcweir     const double d2 = (d / 2.0);
43cdf0e10cSrcweir     m_stdZigZag.append( ::basegfx::B2DPoint( -1.0 - d, -d ) );
44cdf0e10cSrcweir     m_stdZigZag.append( ::basegfx::B2DPoint( -1.0 - d, 1.0 + d ) );
45cdf0e10cSrcweir     m_stdZigZag.append( ::basegfx::B2DPoint( -d, 1.0 + d ) );
46cdf0e10cSrcweir     for ( sal_Int32 pos = (nZigs + 2); pos--; ) {
47cdf0e10cSrcweir         m_stdZigZag.append( ::basegfx::B2DPoint( 0.0, ((pos - 1) * d) + d2 ) );
48cdf0e10cSrcweir         m_stdZigZag.append( ::basegfx::B2DPoint( -d, (pos - 1) * d ) );
49cdf0e10cSrcweir     }
50cdf0e10cSrcweir     m_stdZigZag.setClosed(true);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
operator ()(double t)53cdf0e10cSrcweir ::basegfx::B2DPolyPolygon ZigZagWipe::operator () ( double t )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir     ::basegfx::B2DPolyPolygon res(m_stdZigZag);
56cdf0e10cSrcweir     res.transform(basegfx::tools::createTranslateB2DHomMatrix((1.0 + m_zigEdge) * t, 0.0));
57cdf0e10cSrcweir     return res;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
operator ()(double t)60cdf0e10cSrcweir ::basegfx::B2DPolyPolygon BarnZigZagWipe::operator () ( double t )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     ::basegfx::B2DPolyPolygon res( createUnitRect() );
63cdf0e10cSrcweir     ::basegfx::B2DPolygon poly( m_stdZigZag );
64cdf0e10cSrcweir     poly.flip();
65cdf0e10cSrcweir     basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(
66cdf0e10cSrcweir         (1.0 + m_zigEdge) * (1.0 - t) / 2.0, 0.0));
67cdf0e10cSrcweir     poly.transform( aTransform );
68cdf0e10cSrcweir     res.append( poly );
69cdf0e10cSrcweir     aTransform.scale( -1.0, 1.0 );
70cdf0e10cSrcweir     aTransform.translate( 1.0, m_zigEdge / 2.0 );
71cdf0e10cSrcweir     poly = m_stdZigZag;
72cdf0e10cSrcweir     poly.transform( aTransform );
73cdf0e10cSrcweir     res.append( poly );
74cdf0e10cSrcweir     return res;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir }
78cdf0e10cSrcweir }
79