LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/engine/transitions - randomwipe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 31 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <canvas/debug.hxx>
      22             : #include <basegfx/matrix/b2dhommatrix.hxx>
      23             : #include <basegfx/numeric/ftools.hxx>
      24             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      25             : #include "randomwipe.hxx"
      26             : #include "tools.hxx"
      27             : 
      28             : 
      29             : namespace slideshow {
      30             : namespace internal {
      31             : 
      32           0 : RandomWipe::RandomWipe( sal_Int32 nElements, bool randomBars )
      33           0 :     : m_positions( new ::basegfx::B2DPoint[ nElements ] ),
      34             :       m_nElements( nElements ),
      35           0 :       m_rect( createUnitRect() )
      36             : {
      37           0 :     ::basegfx::B2DHomMatrix aTransform;
      38           0 :     if (randomBars)
      39             :     {
      40           0 :         double edge = (1.0 / nElements);
      41           0 :         for ( sal_Int32 pos = nElements; pos--; )
      42           0 :             m_positions[ pos ].setY( ::basegfx::pruneScaleValue( pos * edge ) );
      43           0 :         aTransform.scale( 1.0, ::basegfx::pruneScaleValue(edge) );
      44             :     }
      45             :     else // dissolve effect
      46             :     {
      47             :         sal_Int32 sqrtElements = static_cast<sal_Int32>(
      48           0 :             sqrt( static_cast<double>(nElements) ) );
      49           0 :         double edge = (1.0 / sqrtElements);
      50           0 :         for ( sal_Int32 pos = nElements; pos--; ) {
      51           0 :             m_positions[ pos ] = ::basegfx::B2DPoint(
      52             :                 ::basegfx::pruneScaleValue( (pos % sqrtElements) * edge ),
      53           0 :                 ::basegfx::pruneScaleValue( (pos / sqrtElements) * edge ) );
      54             :         }
      55           0 :         const double pedge = ::basegfx::pruneScaleValue(edge);
      56           0 :         aTransform.scale( pedge, pedge );
      57             :     }
      58           0 :     m_rect.transform( aTransform );
      59             : 
      60             :     // mix up:
      61           0 :     for ( sal_Int32 pos1 = nElements ; pos1-- ; )
      62             :     {
      63           0 :         const sal_Int32 pos2 = getRandomOrdinal(pos1+1);
      64           0 :         ::std::swap(m_positions[ pos1], m_positions[ pos2 ]);
      65           0 :     }
      66           0 : }
      67             : 
      68           0 : ::basegfx::B2DPolyPolygon RandomWipe::operator () ( double t )
      69             : {
      70           0 :     ::basegfx::B2DPolyPolygon res;
      71           0 :     for ( sal_Int32 pos = static_cast<sal_Int32>(t * m_nElements); pos--; )
      72             :     {
      73           0 :         ::basegfx::B2DPoint const & point = m_positions[ pos ];
      74           0 :         ::basegfx::B2DPolygon poly( m_rect );
      75           0 :         poly.transform(basegfx::tools::createTranslateB2DHomMatrix(point.getX(), point.getY()));
      76           0 :         res.append( poly );
      77           0 :     }
      78           0 :     return res;
      79             : }
      80             : 
      81             : }
      82             : }
      83             : 
      84             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10