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 "waterfallwipe.hxx"
33 #include "transitiontools.hxx"
34
35
36 namespace slideshow {
37 namespace internal {
38
WaterfallWipe(sal_Int32 nElements,bool flipOnYAxis)39 WaterfallWipe::WaterfallWipe( sal_Int32 nElements, bool flipOnYAxis )
40 : m_flipOnYAxis( flipOnYAxis )
41 {
42 const sal_Int32 sqrtElements = static_cast<sal_Int32>(
43 sqrt( static_cast<double>(nElements) ) );
44 const double elementEdge = (1.0 / sqrtElements);
45 m_waterfall.append( ::basegfx::B2DPoint( 0.0, -1.0 ) );
46 for ( sal_Int32 pos = sqrtElements; pos--; )
47 {
48 const sal_Int32 xPos = (sqrtElements - pos - 1);
49 const double yPos = ::basegfx::pruneScaleValue( ((pos + 1) * elementEdge) - 1.0 );
50 m_waterfall.append( ::basegfx::B2DPoint(
51 ::basegfx::pruneScaleValue( xPos * elementEdge ),
52 yPos ) );
53 m_waterfall.append( ::basegfx::B2DPoint(
54 ::basegfx::pruneScaleValue( (xPos + 1) * elementEdge ),
55 yPos ) );
56 }
57 m_waterfall.append( ::basegfx::B2DPoint( 1.0, -1.0 ) );
58 m_waterfall.setClosed(true);
59 }
60
operator ()(double t)61 ::basegfx::B2DPolyPolygon WaterfallWipe::operator () ( double t )
62 {
63 ::basegfx::B2DPolygon poly( m_waterfall );
64 poly.transform(basegfx::tools::createTranslateB2DHomMatrix(0.0, ::basegfx::pruneScaleValue(2.0 * t)));
65 poly.setB2DPoint( 0, ::basegfx::B2DPoint( 0.0, -1.0 ) );
66 poly.setB2DPoint( poly.count()-1, ::basegfx::B2DPoint( 1.0, -1.0 ) );
67
68 return m_flipOnYAxis ? flipOnYAxis( ::basegfx::B2DPolyPolygon(poly) )
69 : ::basegfx::B2DPolyPolygon(poly);
70 }
71
72 }
73 }
74