[英]AS3 - Scale image to full width or height without cut off
我需要在AS3中保持高寬比的情況下縮放圖像。 它應按比例縮放到整個舞台大小,但任何內容都不應刪減。
怎么做?
謝謝你烏里
這樣的事情應該起作用:
// set the scale to fit the width of the image to the width of the stage
var scale:Number = stage.stageWidth / myImage.width;
// if the height of the image will be taller than the stage,
// set the scale to fit the height of the image to the height of the stage
if(myImage.height * scale > stage.stageHeight){
scale = stage.stageHeight / myImage.height;
}
// apply the scale to the image
myImage.scaleX = myImage.scaleY = scale;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.