使用transform.matrix缩放适合flex组件
有人可以告诉我如何使用transform.matrix缩放Canvas,以便组件的内容适合父容器(应用程序),向内或向外
这个函数称为Zoomfit(),我有这样的代码:
public function calcScaleToFitRatio(parentObj:DisplayObject, childObj:DisplayObject):Number{
var retVal:Number = 1;
if (null == childObj) {
return 1;
}
var containerRatio:Number = parentObj.height / parentObj.width;
var contentsRatio:Number = childObj.height / childObj.width;
var isContainerLarger:Boolean = (containerRatio > contentsRatio);
if (true === isContainerLarger) {
retVal = parentObj.width / childObj.width;
} else {
retVal = parentObj.height / childObj.height;
}
return retVal;
}
但是我不能应用于matrix.scale();
someone could tell me how I can zoom a Canvas, with transform.matrix, so that the content of the component fits into the parent container (application), either inward or outward
this function is called Zoomfit(), I have this code:
public function calcScaleToFitRatio(parentObj:DisplayObject, childObj:DisplayObject):Number{
var retVal:Number = 1;
if (null == childObj) {
return 1;
}
var containerRatio:Number = parentObj.height / parentObj.width;
var contentsRatio:Number = childObj.height / childObj.width;
var isContainerLarger:Boolean = (containerRatio > contentsRatio);
if (true === isContainerLarger) {
retVal = parentObj.width / childObj.width;
} else {
retVal = parentObj.height / childObj.height;
}
return retVal;
}
But I can't applied to matrix.scale();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西会起作用,显然将
stretchedCanvas
替换为您正在拉伸的容器的名称。Something like this would work, obviously replace
stretchedCanvas
with name of your container you're stretching.