Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen Rotating a bitmap it cuts corners off
    text
    copied!<p>I rotating some bitmap data in AS3. When ever I start rotating the bitmap the corners get cut off. I'm trying figure out what size the bitmap should be to fit the newly rotated bitmap.</p> <p>The code Im currently using</p> <pre><code>var point:Point=new Point(BMPHolder.x+BMPHolder.width/2,BMPHolder.y+BMPHolder.height/2); var RotateMatrix:Matrix = new Matrix(); var radains:Number = 45 * (Math.PI/180); myMatrix.tx -= point.x; myMatrix.ty -= point.y; myMatrix.rotate(radains); myMatrix.tx += point.x; myMatrix.ty += point.y; preApply = new BitmapData (BMPHolder.width,AdjustY, false); preApply.draw(BMPHolder,myMatrix, null, null, null, false); </code></pre> <p>With the help of the answer i was able to get this working. This is the code I had to add.</p> <pre><code> //Anchor point. xArray.push(0); yArray.push(0); xArray.push((BMPHolder.width * Math.cos(radains)) - (BMPHolder.height * Math.sin(radains))); yArray.push((BMPHolder.width * Math.sin(radains)) + (BMPHolder.height * Math.cos(radains))); xArray.push((BMPHolder.width * Math.cos(radains)) - (BMPHolder.y * Math.sin(radains))); yArray.push((BMPHolder.width * Math.sin(radains)) + (BMPHolder.y * Math.cos(radains))); xArray.push((BMPHolder.x * Math.cos(radains)) - (BMPHolder.height * Math.sin(radains))); yArray.push((BMPHolder.x * Math.sin(radains)) + (BMPHolder.height * Math.cos(radains))); var NewWidth:Number = MaxValue(xArray) - MinValue(xArray); var NewHeight:Number = MaxValue(yArray) - MinValue(yArray); myMatrix.tx -= point.x; myMatrix.ty -= point.y; myMatrix.rotate(radains); myMatrix.tx += Math.abs(NewWidth/2); myMatrix.ty += Math.abs(NewHeight/2); </code></pre> <p>I'm assuming that I could have used the matrix to find all the points but I just did it by hand to keep my sanity. Thanks again</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload