import javafx.scene.CustomNode; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.transform.Scale; import javafx.scene.transform.Translate; /** * @author coffeejolts */ public class FXContainer extends CustomNode{ public var fillDimensions:Boolean = false; public var content:Node; public var width:Integer; public var height:Integer; var group:Group = Group{ content: bind content transforms: bind [translate, scale] } var sf:Number = bind getScale(width, height, content.boundsInLocal.width, content.boundsInLocal.height, fillDimensions); var scale:Scale = Scale{ x: bind sf; y: bind sf; }; var translate:Translate = Translate{ x: bind getTranslation(width, content.boundsInLocal.width * sf); y: bind getTranslation(height, content.boundsInLocal.height * sf); }; function getTranslation(a1:Number, a2:Number):Integer{ return ( a1 - a2) / 2.0 as Integer; } function getScale(vw:Number, vh:Number, sw:Number, sh:Number, fullscreen:Boolean):Number{ var ar_v:Number = vw / vh; var ar_s:Number = sw / sh; var arViewLower:Boolean = ar_v < ar_s; if(fullscreen){ arViewLower = not arViewLower; } if(arViewLower){ return vw / sw; } return vh / sh; } override function create():Node{ return group; } }
This page is an archive of entries from December 2008 listed from newest to oldest.
August 2008 is the previous archive.
October 2009 is the next archive.
Find recent content on the main index or look in the archives to find all content.