public static final void textureFit ( Shape shape , final Image image , final float scaleX , final float scaleY ) { if ( ! validFill ( shape ) ) { return ; } float points [ ] = shape . getPoints ( ) ; Texture t = TextureImpl . getLastBind ( ) ; image . getTexture ( ) . bind ( ) ; final float minX = shape . getX ( ) ; final float minY = shape . getY ( ) ; final float maxX = shape . getMaxX ( ) - minX ; final float maxY = shape . getMaxY ( ) - minY ; fill ( shape , new PointCallback ( ) { public float [ ] preRenderPoint ( Shape shape , float x , float y ) { x -= shape . getMinX ( ) ; y -= shape . getMinY ( ) ; x /= ( shape . getMaxX ( ) - shape . getMinX ( ) ) ; y /= ( shape . getMaxY ( ) - shape . getMinY ( ) ) ; float tx = x * scaleX ; float ty = y * scaleY ; tx = image . getTextureOffsetX ( ) + ( image . getTextureWidth ( ) * tx ) ; ty = image . getTextureOffsetY ( ) + ( image . getTextureHeight ( ) * ty ) ; GL . glTexCoord2f ( tx , ty ) ; return null ; } } ) ; if ( t == null ) { TextureImpl . bindNone ( ) ; } else { t . bind ( ) ; } }
Draw the the given shape filled in with a texture . Only the vertices are set . The colour has to be set independently of this method . This method is required to fit the texture scaleX times across the shape and scaleY times down the shape .