转换后获取旋转对象的宽度和高度 [英] Get the width and height of rotated object after transform
本文介绍了转换后获取旋转对象的宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个问题是对该问题的后续:变换后的宽度/高度.>
我要发布一个新问题,因为该问题仅能解决宽度,而不能解决高度. 公式:
var x = $('#box').width()*Math.cos(rotationAngle)
+ $('#box').height()*Math.sin(rotationAngle);
对于宽度来说效果很好,计算高度的等效公式是什么?
谢谢.
解决方案
这是我想出的最佳工作公式:
var h = $(obj).height() * Math.abs(Math.cos(deg)) + $(obj).width() * Math.abs(Math.sin(deg));
var w = $(obj).width() * Math.abs(Math.cos(deg)) + $(obj).height() * Math.abs(Math.sin(deg));
This question is a followup to the question: width/height after transform.
I am posting a new question because that question only solves the width and not the height. The formula:
var x = $('#box').width()*Math.cos(rotationAngle)
+ $('#box').height()*Math.sin(rotationAngle);
works well for the width, what is the equivalent formula to calculate the height?
Thanks.
解决方案
This is the best working formula I have come up with:
var h = $(obj).height() * Math.abs(Math.cos(deg)) + $(obj).width() * Math.abs(Math.sin(deg));
var w = $(obj).width() * Math.abs(Math.cos(deg)) + $(obj).height() * Math.abs(Math.sin(deg));
这篇关于转换后获取旋转对象的宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文