public static final void texture(final Shape shape, final Image image, final float scaleX, final float scaleY, final ShapeFill fill) {
if (!validFill(shape)) {
return;
}
Texture t = TextureImpl.getLastBind();
image.getTexture().bind();
final float center[] = shape.getCenter();
fill(shape, new PointCallback() {
public float[] preRenderPoint(Shape shape, float x, float y) {
fill.colorAt(shape, x - center[0], y - center[1]).bind();
Vector2f offset = fill.getOffsetAt(shape, x, y);
x += offset.x;
y += offset.y;
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 new float[] {offset.x + x,offset.y + y};
}
});
if (t == null) {
TextureImpl.bindNone();
} else {
t.bind();
}
}