diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml
index 994dd0d681..7aeb140227 100644
--- a/Docs/Luadoc/Lua.xml
+++ b/Docs/Luadoc/Lua.xml
@@ -550,6 +550,7 @@
+
@@ -558,6 +559,7 @@
+
diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml
index d40e06f3b2..1cbd8e95dd 100644
--- a/Docs/Luadoc/LuaDocumentation.xml
+++ b/Docs/Luadoc/LuaDocumentation.xml
@@ -1611,6 +1611,14 @@ save yourself some time, copy this for undocumented things:
Returns the text that is currently set.
+
+ Causes each character of text to be randomly distorted by
+ distortion_percentage of its size when the text is set. The distortion
+ only changes when the text changes.
+
+
+ Turns off distortion.
+
If bJitter is true, move each character of the string around by a small random amount.
diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp
index 2d3998abe9..975e81bf6d 100644
--- a/src/BitmapText.cpp
+++ b/src/BitmapText.cpp
@@ -47,6 +47,8 @@ BitmapText::BitmapText()
m_bRainbowScroll = false;
m_bJitter = false;
+ m_fDistortion= 0.0f;
+ m_bUsingDistortion= false;
m_iWrapWidthPixels = -1;
m_fMaxWidth = 0;
@@ -84,6 +86,8 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
CPY( m_fMaxHeight );
CPY( m_bRainbowScroll );
CPY( m_bJitter );
+ CPY( m_fDistortion );
+ CPY( m_bUsingDistortion );
CPY( m_iVertSpacing );
CPY( m_aVertices );
CPY( m_vpFontPageTextures );
@@ -252,6 +256,22 @@ void BitmapText::BuildChars()
// The amount of padding a line needs:
iY += iPadding;
}
+
+ if( m_bUsingDistortion )
+ {
+ int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*500000.0f );
+ RandomGen rnd( iSeed );
+ for(unsigned int i= 0; i < m_aVertices.size(); i+=4)
+ {
+ float w= m_aVertices[i+2].p.x - m_aVertices[i].p.x;
+ float h= m_aVertices[i+2].p.y - m_aVertices[i].p.y;
+ for(unsigned int ioff= 0; ioff < 4; ++ioff)
+ {
+ m_aVertices[i+ioff].p.x += ((rnd()%9) / 8.0f - .5f) * m_fDistortion * w;
+ m_aVertices[i+ioff].p.y += ((rnd()%9) / 8.0f - .5f) * m_fDistortion * h;
+ }
+ }
+ }
}
void BitmapText::DrawChars( bool bUseStrokeTexture )
@@ -470,6 +490,19 @@ void BitmapText::SetUppercase( bool b )
BuildChars();
}
+void BitmapText::SetDistortion( float f )
+{
+ m_fDistortion= f;
+ m_bUsingDistortion= true;
+ BuildChars();
+}
+
+void BitmapText::UnSetDistortion()
+{
+ m_bUsingDistortion= false;
+ BuildChars();
+}
+
void BitmapText::UpdateBaseZoom()
{
if( m_fMaxWidth == 0 )
@@ -827,6 +860,8 @@ public:
}
static int rainbowscroll( T* p, lua_State *L ) { p->SetRainbowScroll( BArg(1) ); return 0; }
static int jitter( T* p, lua_State *L ) { p->SetJitter( BArg(1) ); return 0; }
+ static int distort( T* p, lua_State *L) { p->SetDistortion( FArg(1) ); return 0; }
+ static int undistort( T* p, lua_State *L) { p->UnSetDistortion(); return 0; }
static int GetText( T* p, lua_State *L ) { lua_pushstring( L, p->GetText() ); return 1; }
static int AddAttribute( T* p, lua_State *L )
{
@@ -851,6 +886,8 @@ public:
ADD_METHOD( settext );
ADD_METHOD( rainbowscroll );
ADD_METHOD( jitter );
+ ADD_METHOD( distort );
+ ADD_METHOD( undistort );
ADD_METHOD( GetText );
ADD_METHOD( AddAttribute );
ADD_METHOD( ClearAttributes );
diff --git a/src/BitmapText.h b/src/BitmapText.h
index bc06c5c406..6a1fad3a00 100644
--- a/src/BitmapText.h
+++ b/src/BitmapText.h
@@ -34,6 +34,8 @@ public:
void SetUppercase( bool b );
void SetRainbowScroll( bool b ) { m_bRainbowScroll = b; }
void SetJitter( bool b ) { m_bJitter = b; }
+ void SetDistortion( float f );
+ void UnSetDistortion();
void SetHorizAlign( float f );
@@ -77,6 +79,8 @@ protected:
float m_fMaxHeight; // 0 = no max
bool m_bRainbowScroll;
bool m_bJitter;
+ bool m_bUsingDistortion;
+ float m_fDistortion;
int m_iVertSpacing;
vector m_aVertices;