public void fillRect ( float x , float y , float width , float height , Image pattern , float offX , float offY ) { int cols = ( ( int ) Math . ceil ( width / pattern . getWidth ( ) ) ) + 2 ; int rows = ( ( int ) Math . ceil ( height / pattern . getHeight ( ) ) ) + 2 ; Rectangle preClip = getWorldClip ( ) ; setWorldClip ( x , y , width , height ) ; predraw ( ) ; // Draw all the quads we need for ( int c = 0 ; c < cols ; c ++ ) { for ( int r = 0 ; r < rows ; r ++ ) { pattern . draw ( c * pattern . getWidth ( ) + x - offX , r * pattern . getHeight ( ) + y - offY ) ; } } postdraw ( ) ; setWorldClip ( preClip ) ; }
Tile a rectangle with a pattern specifing the offset from the top corner that one tile should match