How would I stretch a Bitmap Shader as opposed to tiling it?

302 views Asked by At

In a game that I and another classmate of mine are working on, our barriers have the following code to assign a texture and a color to our canvas objects:

paintColor = new Paint();

Bitmap bitmap = BitmapFactory.decodeResource(GameGUI.ga.getResources(), R.drawable.texture_gravity);
BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

paintColor.setShader(shader);
paintColor.setColorFilter(color);

This works fine for tiling, especially in only staying within the bounds of the canvas object, as we have our own scaling on our objects. However, we would like to be able to stretch a texture over an object, instead of tiling.

I guess this is a long winded explanation, but how would I stretch a texture over an image, instead of tiling?

0

There are 0 answers