Calculate the bounding box’s X, Y, Height and Width of a rotated element via JavaScript

I know this is a bit late, but I’ve written a fiddle for exactly this problem, on an HTML5 canvas: http://jsfiddle.net/oscarpalacious/ZdQKg/ I hope somebody finds it useful! I’m actually not calculating your x,y for the upper left corner of the container. It’s calculated as a result of the offset (code from the fiddle example): this.w … Read more

Wonky text anti-aliasing when rotating with webkit-transform in Chrome

Try triggering the CSS 3d Transform mode with webkit. this changes the way chrome renders -webkit-transform: rotate(.7deg) translate3d( 0, 0, 0); edit There also a Webkit only style declaration -webkit-font-smoothing which takes the values none subpixel-antialiased antialiased where subpixel-antialiased is the default value. Alas, the subpixel antialias is no good solution for rotated text. The … Read more

How to avoid restarting activity when orientation changes on Android

There are various ways to do it, but as given here, using android:configChanges=”keyboardHidden|orientation|screenSize” allows you to listen for the config changes. You then respond to these changes by overriding onConfigurationChanged and calling setContentView. This is the way I’ve been doing it, but I’d be interested to know other people’s thoughts.

Rotate image math (C#)

It depends on which point you want to use as a “center” for your rotation. Let’s call the point to the up and left pointA and the one to the right and below pointB. If you want to rotate around the point A so that point B aligns with it, calculating the rotation angle in … Read more

Rotate a buffered image in Java

As always, the Internet to the rescue. So, this is some code which I hobbled together from other resources/post/blogs which will return a new image which is sized so it will contain the rotated image public BufferedImage rotateImageByDegrees(BufferedImage img, double angle) { double rads = Math.toRadians(angle); double sin = Math.abs(Math.sin(rads)), cos = Math.abs(Math.cos(rads)); int w … Read more

Rotate cv::Mat using cv::warpAffine offsets destination image

I’ve found a solution that doesn’t involve warpAffine(). But before that, I need to state (for future references) that my suspicion was right, you needed to pass the size of the destination when calling warpAffine(): warpAffine(image, rotated_img, rot_matrix, rotated_img.size()); As far as I can tell, the black border (caused by writing at an offset) drawed … Read more