diff options
author | NeilBrown <neilb@suse.de> | 2010-09-28 21:39:19 +1000 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2010-09-28 15:12:03 +0100 |
commit | bb58dbf969a4bfc3bf7dae8577e05bf7756bd99e (patch) | |
tree | 940d7ee5afa93e30eb112cdd41836951159b6a05 /slideshow/source/engine/transitions | |
parent | a677e717e322d39831569972fbd09466c823e25a (diff) |
Improve randomisation in 'dissolve' transition.
The loop for randomizing a list in the dissolve transition is poor.
It randomly chooses two element and swaps them, and does this N/2 times.
Thus a total of N elements are moved.
It is probable that several elements will be swapped multiple times,
leaving it probable that several other elements will not be swapped at all.
This fact is quite visible when transitioning between two very different
slides (e.g. 2 photos). While there is a lot of randomness, there is a
clearly perceptible top-to-bottom 'wipe' happening at the same time.
So change the loop to provide true randomness.
We randomly choose an element for the last position.
Then randomly choose one of the remaining elements for the second
last position, etc.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'slideshow/source/engine/transitions')
-rw-r--r-- | slideshow/source/engine/transitions/randomwipe.cxx | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/slideshow/source/engine/transitions/randomwipe.cxx b/slideshow/source/engine/transitions/randomwipe.cxx index 22c51e38852e..dbd9680f3960 100644 --- a/slideshow/source/engine/transitions/randomwipe.cxx +++ b/slideshow/source/engine/transitions/randomwipe.cxx @@ -68,10 +68,9 @@ RandomWipe::RandomWipe( sal_Int32 nElements, bool randomBars ) m_rect.transform( aTransform ); // mix up: - for ( sal_Int32 i = (nElements / 2); i--; ) + for ( sal_Int32 pos1 = nElements ; i-- ; ) { - const sal_Int32 pos1 = getRandomOrdinal(nElements); - const sal_Int32 pos2 = getRandomOrdinal(nElements); + const sal_Int32 pos2 = getRandomOrdinal(pos1+1); const ::basegfx::B2DPoint point( m_positions[ pos1 ] ); m_positions[ pos1 ] = m_positions[ pos2 ]; m_positions[ pos2 ] = point; |