Ok, let’s see if I can explain what I’m trying to do…
I have an image I am using for a texture that is 600x800 and a tile clip I would like to randomly apply part of the image to as a texture. The tile clip is 100x40.
Now I can do this fine with a repeating texture, because I can just randomize the matrix and not worry about being precise. However, I’m not sure how to randomize the angle of the applied texture without going out of bounds and showing a seam.
Example of this with repeating texture:
textureWidth=600;
textureHeight=800;
var textureBitmap:BitmapData=new BitmapData(textureWidth,textureHeight);
textureBitmap.draw(textureImage);
var matrix:Matrix = new Matrix();
matrix.translate(randRange(0, textureWidth),randRange(0, textureHeight));
var degrees:Number = randRange(-180, 180);
var radians:Number = (degrees/180)*Math.PI;
matrix.rotate(radians);
textureClip.graphics.beginBitmapFill(textureBitmap,matrix,true);
textureClip.graphics.drawRect(0, 0, 100, 40);
textureClip.graphics.endFill();
How could I accomplish something similar with a non-repeating texture? For instance is I angle 45 degrees, how do I translate the matrix to avoid going past the edges. Hope this makes sense.