Refactor TimingData::ScaleRegion(), fixes 297.

This commit is contained in:
Thai Pangsakulyanont
2011-06-26 13:43:30 +07:00
parent c71789b7e7
commit 68f95ce056
4 changed files with 70 additions and 124 deletions
+17 -1
View File
@@ -334,7 +334,23 @@ static inline float ToBeat(int row) { return NoteRowToBeat(row); }
*/
static inline float ToBeat(float beat) { return beat; }
/**
* @brief Scales the position.
* @param T start - the starting row of the scaling region
* @param T length - the length of the scaling region
* @param T newLength - the new length of the scaling region
* @param T position - the position to scale
* @return T the scaled position
*/
template<typename T>
inline T ScalePosition( T start, T length, T newLength, T position )
{
if( position < start )
return position;
if( position >= start + length )
return position - length + newLength;
return start + (position - start) * newLength / length;
}
#endif