Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef Xywh = {x:Float, y:Float, width:Float, height:Float};
- using PlaceTools;
- class PlaceTools
- {
- public static var HORIZONTAL:String = "horizontal";
- public static function rightOf(target:Xywh, ref:Xywh, ?padding:Int=0, ?align:Bool=true, ?width:Float=0, ?height:Float=0):Void
- {
- target.x = ref.x + ref.width + padding;
- if(align) target.y = ref.y;
- if(width!=0)target.width=width;
- if(height!=0)target.height=height;
- }
- public static function distribute(arr:Array<Dynamic>, ?padding:Int=0, ?dtype:String="horizontal")
- {
- for(i in 1...arr.length)
- {
- switch(dtype)
- {
- case HORIZONTAL: arr[i].rightOf(arr[i-1], padding);
- default: trace(not implemented in this example);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment