Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [SIZE="0"][url=http://villavu.com/forum/showthread.php?t=82205]String Handling Commands[/url] | [url=http://villavu.com/forum/showthread.php?t=104687]Point Commands[/url] |[/SIZE] [SIZE="5"][COLOR="red"]Box Commands[/COLOR][/SIZE][SIZE="0"] | [url=http://villavu.com/forum/showthread.php?t=104689]Integer Commands[/url][/SIZE]
- Here is another little "topic of contributions" from me to the SRL community! :p
- Really hoping to get this one someday as big as String Handling Commands topic.
- Added small examples for all commands, just to show how they work (due to missing those code comments), although most of the functions/procedures are pretty much self-explanatory...
- Also most (if not all) will have small explanations included aswell.
- [b]List of [color=blue]Functions[/color] & [color=blue]Procedures[/color]:[/b]
- [code][u]### / Date Added / Command Name[/u]
- 000 / 07-05-2013 / Box()
- 001 / 07-05-2013 / BoxCenter()
- 002 / 07-15-2013 / BoxPixelCount()
- 003 / 07-05-2013 / BoxFromPoint()
- 004 / 07-05-2013 / BoxToPoint()
- 005 / 07-05-2013 / PointsToBox()
- 006 / 07-05-2013 / CombineBoxes()
- 007 / 07-05-2013 / SetBoxConstraints()
- 008 / 07-05-2013 / ResizeBoxEx() [*]
- 009 / 07-05-2013 / FixBox()
- 010 / 07-05-2013 / BoxesOverlap()
- 011 / 07-05-2013 / BoxDimensions()
- 012 / 07-05-2013 / BoxCentralization() [*]
- 013 / 07-05-2013 / CountBoxesInBoxBySize()
- 014 / 07-05-2013 / GetBoxesInBoxBySize()
- 015 / 07-05-2013 / BoxInBox()
- 016 / 07-05-2013 / BoxInsideBox()
- 017 / 07-05-2013 / BoxInBoxes()
- 018 / 07-05-2013 / BoxInsideBoxes()
- 019 / 07-05-2013 / ValidBox()
- 020 / 07-05-2013 / SameBoxes()
- 021 / 07-05-2013 / SimilarBoxDimensionsEx()
- 022 / 07-05-2013 / SimilarBoxDimensions()
- 023 / 07-05-2013 / MergeTBA()
- 024 / 07-05-2013 / BoxInTPA()
- 025 / 07-05-2013 / TBABounds()
- 026 / 07-05-2013 / TBAGrid()
- 027 / 07-05-2013 / TBARow()
- 028 / 07-05-2013 / TBAColumn()
- 029 / 07-05-2013 / TBACopyEx()
- 030 / 07-05-2013 / TBAClone()
- 031 / 07-05-2013 / TBACombine()
- 032 / 07-05-2013 / TBADelete()
- 033 / 07-05-2013 / TBARemove()
- 034 / 07-05-2013 / TBASame()
- 035 / 07-05-2013 / TBAInsert()
- 036 / 07-05-2013 / TBAAppend()
- 037 / 07-05-2013 / TBAAdd()
- 038 / 07-05-2013 / TBAPlant()
- 039 / 07-05-2013 / TBAUnique()
- 040 / 07-05-2013 / TBARandomizeEx()
- 041 / 07-05-2013 / TBARandomize()
- 042 / 07-05-2013 / TBAContains()
- 043 / 07-05-2013 / TBAPositions()
- 044 / 07-05-2013 / TBAGet()
- 045 / 07-05-2013 / TBAMove()
- 046 / 07-05-2013 / TBAToParts() [*]
- 047 / 07-05-2013 / TBACenterPointsEx()
- 048 / 07-05-2013 / TBACenterPoints()
- 049 / 07-05-2013 / ATBAMerge()
- [i]* = Amount of custom types required.[/i][/code]
- [spoiler="Box"]
- [simba]{==============================================================================]
- Explanation: Creates a TBox with X1,Y1,X2,Y2 values..
- Automatically corrects/fixes the incorrect values.
- [==============================================================================}
- function Box(X1, Y1, X2, Y2: Integer): TBox;
- begin
- Result := IntToBox(X1, Y1, X2, Y2);
- if (Result.X1 > Result.X2) then
- Swap(Result.X1, Result.X2);
- if (Result.Y1 > Result.Y2) then
- Swap(Result.Y1, Result.Y2);
- end;
- begin
- WriteLn(Box(100, 100, 100, 100));
- WriteLn(Box(100, 85, 85, 100));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxCenter"]
- [simba]{==============================================================================]
- Explanation: Returns the center point of bx.
- [==============================================================================}
- function BoxCenter(bx: TBox): TPoint;
- begin
- if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2)) then
- begin
- if (bx.X1 > bx.X2) then
- Swap(bx.X1, bx.X2);
- if (bx.Y1 > bx.Y2) then
- Swap(bx.Y1, bx.Y2);
- end;
- Result := Point(Round(bx.X1 + ((bx.X2 - bx.X1) div 2)), Round(bx.Y1 + ((bx.Y2 - bx.Y1) div 2)));
- end;
- begin
- WriteLn(ToStr(BoxCenter(IntToBox(1, 1, 50, 50))));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxPixelCount"]
- [simba]{==============================================================================]
- Explanation: Calculates the amount of pixels in TBox (bx).
- Returns -1 with invalid TBox.
- [==============================================================================}
- function BoxPixelCount(bx: TBox): Integer;
- begin
- if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2)) then
- Result := -1
- else
- Result := Integer(((bx.X2 - bx.X1) + 1) * ((bx.Y2 - bx.Y1) + 1));
- end;
- var
- w, h: Integer;
- begin
- ClearDebug;
- GetClientDimensions(w, h);
- WriteLn('Client pixel count: ' + IntToStr(BoxPixelCount(IntToBox(0, 0, (w - 1), (h - 1)))));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxFromPoint"]
- [simba]{==============================================================================]
- Explanation: Creates box from point, where pt is the middle point of the box.
- wRadius = width radius, hRadius = height radius
- [==============================================================================}
- function BoxFromPoint(pt: TPoint; wRadius, hRadius: Integer): TBox;
- begin
- if (wRadius < 0) then
- wRadius := 0;
- if (hRadius < 0) then
- hRadius := 0;
- Result := IntToBox((pt.X - wRadius), (pt.Y - hRadius), (pt.X + wRadius), (pt.Y + hRadius));
- end;
- begin
- WriteLn(BoxFromPoint(Point(200, 200), 100, 100));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxToPoint"]
- [simba]{==============================================================================]
- Explanation: Creates box to point, where pt is the start point of the box.
- width and height can be positive or negative.
- [==============================================================================}
- function BoxToPoint(pt: TPoint; width, height: Integer): TBox;
- var
- o: TPoint;
- begin
- if ((width < 0) or (height < 0)) then
- begin
- if (width < 0) then
- o.X := Integer(width);
- if (height < 0) then
- o.Y := Integer(height);
- pt.X := (pt.X + o.X);
- pt.Y := (pt.Y + o.Y);
- end;
- {$IFNDEF Lape}
- Result := IntToBox(pt.X, pt.Y, (pt.X + iAbs(width - 1)), (pt.Y + iAbs(height - 1)));
- {$ELSE}
- Result := IntToBox(pt.X, pt.Y, (pt.X + Abs(width - 1)), (pt.Y + Abs(height - 1)));
- {$ENDIF}
- end;
- begin
- WriteLn(BoxToPoint(Point(50, 50), 100, 100));
- end.[/simba]
- [/spoiler]
- [spoiler="PointsToBox"]
- [simba]{==============================================================================]
- Explanation: Creates a TBox with 2 points (p1, p2)..
- Automatically corrects/fixes the incorrect values.
- [==============================================================================}
- function PointsToBox(p1, p2: TPoint): TBox;
- begin
- Result := IntToBox(Min(p1.X, p2.X), Min(p1.Y, p2.Y), Max(p1.X, p2.X), Max(p1.Y, p2.Y));
- end;
- begin
- WriteLn(PointsToBox(Point(50, 50), Point(10, 10)));
- end.[/simba]
- [/spoiler]
- [spoiler="CombineBoxes"]
- [simba]{==============================================================================]
- Explanation: Combines 2 boxes (a and b) to 1 box.
- [==============================================================================}
- function CombineBoxes(a, b: TBox): TBox;
- begin
- Result.X1 := Min(Min(a.X1, a.X2), Min(b.X1, b.X2));
- Result.Y1 := Min(Min(a.Y1, a.Y2), Min(b.Y1, b.Y2));
- Result.X2 := Max(Max(a.X1, a.X2), Max(b.X1, b.X2));
- Result.Y2 := Max(Max(a.Y1, a.Y2), Max(b.Y1, b.Y2));
- end;
- var
- a, b: TBox;
- begin
- a := IntToBox(10, 50, 20, 100);
- b := IntToBox(50, 10, 100, 20);
- WriteLn(CombineBoxes(a, b));
- end.[/simba]
- [/spoiler]
- [spoiler="SetBoxConstraints"]
- [simba]{==============================================================================]
- Explanation: Set minimum / maximum size to bx.
- size.X1 = min. X1, size.Y1 = min. Y1, size.X2 = max. X2, size.Y2 = max. Y2
- Returns true if constraints were set to bx.
- [==============================================================================}
- function SetBoxConstraints(var bx: TBox; size: TBox): Boolean;
- var
- tmp: TBox;
- begin
- if ((size.X1 <= size.X2) and (size.Y1 <= size.Y2)) then
- begin
- tmp := TBox(bx);
- if (bx.X1 < size.X1) then
- bx.X1 := Integer(size.X1);
- if (bx.X1 > size.X2) then
- bx.X1 := Integer(size.X2);
- if (bx.Y1 < size.Y1) then
- bx.Y1 := Integer(size.Y1);
- if (bx.Y1 > size.Y2) then
- bx.Y1 := Integer(size.Y2);
- if (bx.X2 > size.X2) then
- bx.X2 := Integer(size.X2);
- if (bx.X2 < size.X1) then
- bx.X2 := Integer(size.X1);
- if (bx.Y2 > size.Y2) then
- bx.Y2 := Integer(size.Y2);
- if (bx.Y2 < size.Y1) then
- bx.Y2 := Integer(size.Y1);
- Result := ((bx.X1 <> tmp.X1) or (bx.Y1 <> tmp.Y1) or (bx.X2 <> tmp.X2) or (bx.Y2 <> tmp.Y2));
- end else
- Result := False;
- end;
- var
- b: TBox;
- begin
- b := IntToBox(100, 100, 400, 400);
- if SetBoxConstraints(b, IntToBox(250, 250, 500, 500)) then
- WriteLn(b);
- b := IntToBox(100, 100, 400, 400);
- if SetBoxConstraints(b, IntToBox(0, 0, 300, 300)) then
- WriteLn(b);
- end.[/simba]
- [/spoiler]
- [spoiler="ResizeBoxEx"]
- [simba]{==============================================================================]
- Explanation: Methods for box resizing (for ResizeBoxEx).
- [==============================================================================}
- type
- TResizeMethod = (rmFull, rmWidth, rmHeight, rmUp, rmDown, rmLeft, rmRight, rmTopLeft, rmTopRight, rmBottomLeft, rmBottomRight);
- {==============================================================================]
- Explanation: Resizes bx by sizeChange..
- Contains 11 methods (MSSL_TResizeMethod).
- Negative sizeChange = Shrinking, Positive sizeChange = Expanding.
- [==============================================================================}
- procedure ResizeBoxEx(var bx: TBox; method: TResizeMethod; sizeChange: Integer);
- begin
- if (sizeChange <> 0) then
- case method of
- rmFull: bx := IntToBox((bx.X1 - sizeChange), (bx.Y1 - sizeChange), (bx.X2 + sizeChange), (bx.Y2 + sizeChange)); // FULL AREA
- rmWidth: bx := IntToBox((bx.X1 - sizeChange), bx.Y1, (bx.X2 + sizeChange), bx.Y2); // WIDTH
- rmHeight: bx := IntToBox(bx.X1, (bx.Y1 - sizeChange), bx.X2, (bx.Y2 + sizeChange)); // HEIGHT
- rmUp: bx := IntToBox(bx.X1, (bx.Y1 - sizeChange), bx.X2, bx.Y2); // UP
- rmDown: bx := IntToBox(bx.X1, bx.Y1, bx.X2, (bx.Y2 + sizeChange)); // DOWN
- rmLeft: bx := IntToBox((bx.X1 - sizeChange), bx.Y1, bx.X2, bx.Y2); // LEFT
- rmRight: bx := IntToBox(bx.X1, bx.Y1, (bx.X2 + sizeChange), bx.Y2); // RIGHT
- rmTopLeft: bx := IntToBox((bx.X1 - sizeChange), (bx.Y1 - sizeChange), bx.X2, bx.Y2); // TOP-LEFT CORNER
- rmTopRight: bx := IntToBox(bx.X1, (bx.Y1 - sizeChange), (bx.X2 + sizeChange), bx.Y2); // TOP-RIGHT CORNER
- rmBottomLeft: bx := IntToBox((bx.X1 - sizeChange), bx.Y1, bx.X2, (bx.Y2 + sizeChange)); // BOTTOM-LEFT CORNER
- rmBottomRight: bx := IntToBox(bx.X1, bx.Y1, (bx.X2 + sizeChange), (bx.Y2 + sizeChange)); // BOTTOM-RIGHT CORNER
- end;
- end;
- var
- r: array of TResizeMethod;
- i, p, x, y: Integer;
- b: TBox;
- begin
- r := [rmUp, rmDown, rmLeft, rmRight, rmTopLeft, rmTopRight, rmBottomLeft, rmBottomRight, rmWidth, rmHeight, rmFull];
- DisplayDebugImgWindow(500, 500);
- b := IntToBox(246, 246, 254, 254);
- p := CreateBitmap(500, 500);
- for x := b.X1 to b.X2 do
- for y := b.Y1 to b.Y2 do
- FastSetPixel(p, x, y, 16777215);
- DrawBitmapDebugImg(p);
- FreeBitmap(p);
- for i := 0 to High(r) do
- begin
- Wait(300);
- ResizeBoxEx(b, r[i], 5);
- p := CreateBitmap(500, 500);
- for x := b.X1 to b.X2 do
- for y := b.Y1 to b.Y2 do
- FastSetPixel(p, x, y, 16777215);
- DrawBitmapDebugImg(p);
- FreeBitmap(p);
- Wait(1200);
- end;
- end.[/simba]
- [/spoiler]
- [spoiler="FixBox"]
- [simba]{==============================================================================]
- Explanation: Fixes the bx. Swaps incorrectly set values (XS/YS > XE/YE).
- Returns true if bx was fixed.
- Example: (200*, 100, 100*, 200) => (100, 100, 200, 200)
- [==============================================================================}
- function FixBox(var bx: TBox): Boolean;
- var
- o: TBox;
- begin
- o := bx;
- if (bx.X1 > bx.X2) then
- Swap(bx.X1, bx.X2);
- if (bx.Y1 > bx.Y2) then
- Swap(bx.Y1, bx.Y2);
- Result := ((o.X1 <> bx.X1) or (o.Y1 <> bx.Y1) or (o.X2 <> bx.X2) or (o.Y2 <> bx.Y2));
- end;
- var
- a, b: TBox;
- begin
- a := IntToBox(100, 100, 80, 80);
- b := IntToBox(80, 80, 100, 100);
- if FixBox(a) then
- WriteLn('Fixed A!');
- if FixBox(b) then
- WriteLn('Fixed B!');
- WriteLn(ToStr(a));
- WriteLn(ToStr(b));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxesOverlap"]
- [simba]{==============================================================================]
- Explanation: Returns true if a and b are in anykind of contact with each other.
- [==============================================================================}
- function BoxesOverlap(a, b: TBox): Boolean;
- begin
- Result := not ((a.X1 > b.X2) or (a.X2 < b.X1) or (a.Y1 > b.Y2) or (a.Y2 < b.Y1));
- end;
- var
- a, t: TPointArray;
- i, p, x, y: Integer;
- b, c: TBox;
- begin
- b := IntToBox(50, 50, 60, 60);
- a := TPAFromBox(b);
- DisplayDebugImgWindow(100, 100);
- for x := 0 to 89 do
- for y := 0 to 89 do
- begin
- p := CreateBitmap(100, 100);
- for i := 0 to High(a) do
- FastSetPixel(p, a[i].X, a[i].Y, 255);
- c := IntToBox(x, y, (x + 9), (y + 9));
- t := TPAFromBox(c);
- for i := 0 to High(t) do
- FastSetPixel(p, t[i].X, t[i].Y, 16711680);
- SetLength(t, 0);
- DrawBitmapDebugImg(p);
- FreeBitmap(p);
- if BoxesOverlap(b, c) then
- begin
- WriteLn('OVERLAPPING!');
- Exit;
- end;
- end;
- SetLength(a, 0);
- end.[/simba]
- [/spoiler]
- [spoiler="BoxDimensions"]
- [simba]procedure BoxDimensions(bx: TBox; var w, h: Integer);
- begin
- w := ((bx.X2 - bx.X1) + 1);
- h := ((bx.Y2 - bx.Y1) + 1);
- end;
- var
- width, height: Integer;
- begin
- BoxDimensions(IntToBox(220, 140, 280, 200), width, height);
- WriteLn(IntToStr(width) + 'x' + IntToStr(height));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxCentralization"]
- [simba]{==============================================================================]
- Explanation: Centering methods for BoxCentralization.
- [==============================================================================}
- type
- TCenterMethod = (cmWidthwise, cmHeightwise, cmBoth);
- {==============================================================================]
- Explanation: Sets inner bx to center of outer bx. Contains 3 methods.
- muWidthHeight = center width & heightwise, muWidth = center widthwise, muHeight = center heightwise.
- [==============================================================================}
- procedure BoxCentralization(var inner_bx: TBox; outer_bx: TBox; method: TCenterMethod);
- var
- o: TPoint;
- begin
- case method of
- cmBoth: o := Point(((Round(outer_bx.X1 + ((outer_bx.X2 - outer_bx.X1) / 2)) - (((inner_bx.X2 - inner_bx.X1) + 1) div 2)) - inner_bx.X1), ((Round(outer_bx.Y1 + ((outer_bx.Y2 - outer_bx.Y1) / 2)) - (((inner_bx.Y2 - inner_bx.Y1) + 1) div 2)) - inner_bx.Y1));
- cmWidthwise: o := Point(((Round(outer_bx.X1 + ((outer_bx.X2 - outer_bx.X1) / 2)) - (((inner_bx.X2 - inner_bx.X1) + 1) div 2)) - inner_bx.X1), 0);
- cmHeightwise: o := Point(0, ((Round(outer_bx.Y1 + ((outer_bx.Y2 - outer_bx.Y1) / 2)) - (((inner_bx.Y2 - inner_bx.Y1) + 1) div 2)) - inner_bx.Y1));
- else
- Exit;
- end;
- inner_bx := IntToBox((inner_bx.X1 + o.X), (inner_bx.Y1 + o.Y), (inner_bx.X2 + o.X), (inner_bx.Y2 + o.Y));
- end;
- var
- a, b: TBox;
- x, y, i: Integer;
- t, p: TPointArray;
- begin
- a := IntToBox(50, 50, 99, 99);
- p := TPAFromBox(a);
- b := IntToBox(0, 0, 24, 24);
- t := TPAFromBox(b);
- i := CreateBitmap(150, 150);
- for x := a.X1 to a.X2 do
- for y := a.Y1 to a.Y2 do
- FastSetPixel(i, x, y, 16711680);
- BoxCentralization(b, a, cmBoth); // You can change that cmWidthHeight - see the effect.. :)
- for x := b.X1 to b.X2 do
- for y := b.Y1 to b.Y2 do
- FastSetPixel(i, x, y, 16777215);
- DisplayDebugImgWindow(150, 150);
- DrawBitmapDebugImg(i);
- FreeBitmap(i);
- SetLength(p, 0);
- SetLength(t, 0);
- WriteLn('a: ' + ToStr(a) + ', b: ' + ToStr(b));
- end.[/simba]
- [/spoiler]
- [spoiler="CountBoxesInBoxBySize"]
- [simba]{==============================================================================]
- Explanation: Returns count of ALL the possible boxes in a box (bx) by size (width*height).
- [==============================================================================}
- function CountBoxesInBoxBySize(bx: TBox; width, height: Integer): Integer;
- var
- w, h: Integer;
- begin
- Result := 0;
- if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2) or (width < 1) or (height < 1)) then
- Exit;
- w := ((bx.X2 - bx.X1) + 1);
- h := ((bx.Y2 - bx.Y1) + 1);
- if ((width < (w + 1)) and (height < (h + 1))) then
- Result := ((h - (height - 1)) * (w - (width - 1)));
- end;
- begin
- WriteLn(CountBoxesInBoxBySize(IntToBox(25, 25, 50, 50), 25, 25));
- end.[/simba]
- [/spoiler]
- [spoiler="GetBoxesInBoxBySize"]
- [simba]{==============================================================================]
- Explanation: Returns ALL the possible boxes in a box (bx) by size (width*height).
- [==============================================================================}
- function GetBoxesInBoxBySize(bx: TBox; width, height: Integer): TBoxArray;
- var
- r, c, w, h, x, y: Integer;
- begin
- if ((bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2) and (width > 0) and (height > 0)) then
- begin
- w := ((bx.X2 - bx.X1) + 1);
- h := ((bx.Y2 - bx.Y1) + 1);
- if ((width < (w + 1)) and (height < (h + 1))) then
- begin
- r := (h - (height - 1));
- c := (w - (width - 1));
- SetLength(Result, (r * c));
- for y := bx.Y1 to (bx.Y1 + (r - 1)) do
- for x := bx.X1 to (bx.X1 + (c - 1)) do
- Result[(((y - bx.Y1) * c) + (x - bx.X1))] := IntToBox(x, y, (x + (width - 1)), (y + (height - 1)));
- end else
- SetLength(Result, 0);
- end else
- SetLength(Result, 0);
- end;
- begin
- WriteLn(GetBoxesInBoxBySize(IntToBox(25, 25, 50, 50), 25, 25));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxInBox"]
- [simba]{==============================================================================]
- Explanation: Returns true if inner_bx is in/within outer_bx.
- [==============================================================================}
- function BoxInBox(inner_bx, outer_bx: TBox): Boolean;
- begin
- Result := ((inner_bx.X1 >= outer_bx.X1) and (inner_bx.X1 <= outer_bx.X2) and (inner_bx.X2 >= outer_bx.X1) and (inner_bx.X2 <= outer_bx.X2) and (inner_bx.Y1 >= outer_bx.Y1) and (inner_bx.Y1 <= outer_bx.Y2) and (inner_bx.Y2 >= outer_bx.Y1) and (inner_bx.Y2 <= outer_bx.Y2));
- end;
- var
- a, t: TPointArray;
- i, p, x, y: Integer;
- b, c: TBox;
- begin
- b := IntToBox(50, 50, 61, 61);
- a := TPAFromBox(b);
- DisplayDebugImgWindow(100, 100);
- for x := 0 to 89 do
- for y := 0 to 89 do
- begin
- p := CreateBitmap(100, 100);
- for i := 0 to High(a) do
- FastSetPixel(p, a[i].X, a[i].Y, 255);
- c := IntToBox(x, y, (x + 9), (y + 9));
- t := TPAFromBox(c);
- for i := 0 to High(t) do
- FastSetPixel(p, t[i].X, t[i].Y, 16711680);
- SetLength(t, 0);
- DrawBitmapDebugImg(p);
- FreeBitmap(p);
- if BoxInBox(c, b) then
- begin
- WriteLn('IN!');
- Exit;
- end;
- end;
- SetLength(a, 0);
- end.[/simba]
- [/spoiler]
- [spoiler="BoxInsideBox"]
- [simba]{==============================================================================]
- Explanation: Returns true if inner_bx is INSIDE outer_bx.
- [==============================================================================}
- function BoxInsideBox(inner_bx, outer_bx: TBox): Boolean;
- begin
- Result := ((inner_bx.X1 > outer_bx.X1) and (inner_bx.X1 < outer_bx.X2) and (inner_bx.X2 > outer_bx.X1) and (inner_bx.X2 < outer_bx.X2) and (inner_bx.Y1 > outer_bx.Y1) and (inner_bx.Y1 < outer_bx.Y2) and (inner_bx.Y2 > outer_bx.Y1) and (inner_bx.Y2 < outer_bx.Y2));
- end;
- var
- a, t: TPointArray;
- i, p, x, y: Integer;
- b, c: TBox;
- begin
- b := IntToBox(50, 50, 61, 61);
- a := TPAFromBox(b);
- DisplayDebugImgWindow(100, 100);
- for x := 0 to 89 do
- for y := 0 to 89 do
- begin
- p := CreateBitmap(100, 100);
- for i := 0 to High(a) do
- FastSetPixel(p, a[i].X, a[i].Y, 255);
- c := IntToBox(x, y, (x + 9), (y + 9));
- t := TPAFromBox(c);
- for i := 0 to High(t) do
- FastSetPixel(p, t[i].X, t[i].Y, 16711680);
- SetLength(t, 0);
- DrawBitmapDebugImg(p);
- FreeBitmap(p);
- if BoxInsideBox(c, b) then
- begin
- WriteLn('INSIDE!');
- Exit;
- end;
- end;
- SetLength(a, 0);
- end.[/simba]
- [/spoiler]
- [spoiler="BoxInBoxes"]
- [simba]{==============================================================================]
- Explanation: Returns true if inner_bx is in/within any of the outer_bxs.
- [==============================================================================}
- function BoxInBoxes(inner_bx: TBox; outer_bxs: TBoxArray): Boolean;
- var
- h, i: Integer;
- begin
- h := High(outer_bxs);
- for i := 0 to h do
- begin
- Result := ((inner_bx.X1 >= outer_bxs[i].X1) and (inner_bx.X1 <= outer_bxs[i].X2) and (inner_bx.X2 >= outer_bxs[i].X1) and (inner_bx.X2 <= outer_bxs[i].X2) and (inner_bx.Y1 >= outer_bxs[i].Y1) and (inner_bx.Y1 <= outer_bxs[i].Y2) and (inner_bx.Y2 >= outer_bxs[i].Y1) and (inner_bx.Y2 <= outer_bxs[i].Y2));
- if Result then
- Exit;
- end;
- Result := False;
- end;
- var
- a, t: TPointArray;
- i, p, x, y: Integer;
- b, c, d: TBox;
- begin
- b := IntToBox(50, 50, 61, 61);
- d := IntToBox(53, 20, 64, 31);
- a := CombineTPA(TPAFromBox(b), TPAFromBox(d));
- DisplayDebugImgWindow(100, 100);
- for x := 0 to 89 do
- for y := 0 to 89 do
- begin
- p := CreateBitmap(100, 100);
- for i := 0 to High(a) do
- FastSetPixel(p, a[i].X, a[i].Y, 255);
- c := IntToBox(x, y, (x + 9), (y + 9));
- t := TPAFromBox(c);
- for i := 0 to High(t) do
- FastSetPixel(p, t[i].X, t[i].Y, 16711680);
- SetLength(t, 0);
- DrawBitmapDebugImg(p);
- FreeBitmap(p);
- if BoxInBoxes(c, [b, d]) then
- begin
- WriteLn('IN!');
- Exit;
- end;
- end;
- SetLength(a, 0);
- end.[/simba]
- [/spoiler]
- [spoiler="BoxInsideBoxes"]
- [simba]{==============================================================================]
- Explanation: Returns true if inner_bx is INSIDE any of the outer_bxs.
- [==============================================================================}
- function BoxInsideBoxes(inner_bx: TBox; outer_bxs: TBoxArray): Boolean;
- var
- h, i: Integer;
- begin
- h := High(outer_bxs);
- for i := 0 to h do
- begin
- Result := ((inner_bx.X1 > outer_bxs[i].X1) and (inner_bx.X1 < outer_bxs[i].X2) and (inner_bx.X2 > outer_bxs[i].X1) and (inner_bx.X2 < outer_bxs[i].X2) and (inner_bx.Y1 > outer_bxs[i].Y1) and (inner_bx.Y1 < outer_bxs[i].Y2) and (inner_bx.Y2 > outer_bxs[i].Y1) and (inner_bx.Y2 < outer_bxs[i].Y2));
- if Result then
- Exit;
- end;
- Result := False;
- end;
- var
- a, t: TPointArray;
- i, p, x, y: Integer;
- b, c, d: TBox;
- begin
- b := IntToBox(50, 50, 61, 61);
- d := IntToBox(53, 20, 64, 31);
- a := CombineTPA(TPAFromBox(b), TPAFromBox(d));
- DisplayDebugImgWindow(100, 100);
- for x := 0 to 89 do
- for y := 0 to 89 do
- begin
- p := CreateBitmap(100, 100);
- for i := 0 to High(a) do
- FastSetPixel(p, a[i].X, a[i].Y, 255);
- c := IntToBox(x, y, (x + 9), (y + 9));
- t := TPAFromBox(c);
- for i := 0 to High(t) do
- FastSetPixel(p, t[i].X, t[i].Y, 16711680);
- SetLength(t, 0);
- DrawBitmapDebugImg(p);
- FreeBitmap(p);
- if BoxInsideBoxes(c, [b, d]) then
- begin
- WriteLn('INSIDE!');
- Exit;
- end;
- end;
- SetLength(a, 0);
- end.[/simba]
- [/spoiler]
- [spoiler="ValidBox"]
- [simba]{==============================================================================]
- Explanation: Returns true if bx is valid (X1 <= X2 AND Y1 <= Y2).
- [==============================================================================}
- function ValidBox(bx: TBox): Boolean;
- begin
- Result := ((bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2));
- end;
- begin
- if ValidBox(IntToBox(999, 999, 100, 100)) then
- WriteLn('What?! This is not valid...');
- if ValidBox(IntToBox(100, 100, 999, 999)) then
- WriteLn('Now we are talking. ;)');
- end.[/simba]
- [/spoiler]
- [spoiler="SameBoxes"]
- [simba]{==============================================================================]
- Explanation: Returns true if bx1 and bx2 are identical.
- [==============================================================================}
- function SameBoxes(bx1, bx2: TBox): Boolean;
- begin
- Result := ((bx1.X1 = bx2.X1) and (bx1.Y1 = bx2.Y1) and (bx1.X2 = bx2.X2) and (bx1.Y2 = bx2.Y2));
- end;
- begin
- if SameBoxes(IntToBox(0, 0, 0, 0), IntToBox(1, 1, 1, 1)) then
- WriteLn('NOPE!');
- if SameBoxes(IntToBox(1, 2, 3, 4), IntToBox(1, 2, 3, 4)) then
- WriteLn('YEAH!');
- end.[/simba]
- [/spoiler]
- [spoiler="SimilarBoxDimensionsEx"]
- [simba]{==============================================================================]
- Explanation: Returns true if the dimensions from boxes bx1 and bx2
- are within maxWDif (max width differency) and maxHDif (max height differency).
- [==============================================================================}
- function SimilarBoxDimensionsEx(bx1, bx2: TBox; maxWDif, maxHDif: Integer): Boolean;
- begin
- {$IFNDEF Lape}
- Result := ((IAbs(((bx2.X2 - bx2.X1) + 1) - ((bx1.X2 - bx1.X1) + 1)) <= maxWDif) and (IAbs(((bx2.Y2 - bx2.Y1) + 1) - ((bx1.Y2 - bx1.Y1) + 1)) <= maxHDif));
- {$ELSE}
- Result := ((Abs(((bx2.X2 - bx2.X1) + 1) - ((bx1.X2 - bx1.X1) + 1)) <= maxWDif) and (Abs(((bx2.Y2 - bx2.Y1) + 1) - ((bx1.Y2 - bx1.Y1) + 1)) <= maxHDif));
- {$ENDIF}
- end;
- const
- WIDTH_DIFFERENCE = 2;
- HEIGHT_DIFFERENCE = 2;
- var
- TBA: TBoxArray;
- a, b: Integer;
- begin
- TBA := [IntToBox(10, 10, 20, 20), IntToBox(8, 8, 22, 22), IntToBox(12, 12, 20, 20),
- IntToBox(7, 7, 21, 21), IntToBox(11, 11, 20, 20), IntToBox(9, 9, 23, 23)];
- for a := 0 to (High(TBA) - 1) do
- for b := (a + 1) to High(TBA) do
- if SimilarBoxDimensionsEx(TBA[a], TBA[b], WIDTH_DIFFERENCE, HEIGHT_DIFFERENCE) then
- WriteLn('TBA[' + IntToStr(a) + '] (' + IntToStr(((TBA[a].X2 - TBA[a].X1) + 1)) + 'x' + IntToStr(((TBA[a].Y2 - TBA[a].Y1) + 1)) + ') and TBA[' + IntToStr(b) + '] (' + IntToStr(((TBA[b].X2 - TBA[b].X1) + 1)) + 'x' + IntToStr(((TBA[b].Y2 - TBA[b].Y1) + 1)) + ') are similar.');
- end.[/simba]
- [/spoiler]
- [spoiler="SimilarBoxDimensions"]
- [simba]{==============================================================================]
- Explanation: Returns true if the dimensions from boxes bx1 and bx2
- are within dif (differency).
- [==============================================================================}
- function SimilarBoxDimensions(bx1, bx2: TBox; dif: Integer): Boolean;
- begin
- {$IFNDEF Lape}
- Result := ((IAbs(((bx2.X2 - bx2.X1) + 1) - ((bx1.X2 - bx1.X1) + 1)) <= dif) and (IAbs(((bx2.Y2 - bx2.Y1) + 1) - ((bx1.Y2 - bx1.Y1) + 1)) <= dif));
- {$ELSE}
- Result := ((Abs(((bx2.X2 - bx2.X1) + 1) - ((bx1.X2 - bx1.X1) + 1)) <= dif) and (Abs(((bx2.Y2 - bx2.Y1) + 1) - ((bx1.Y2 - bx1.Y1) + 1)) <= dif));
- {$ENDIF}
- end;
- const
- DIFFERENCE = 2;
- var
- TBA: TBoxArray;
- a, b: Integer;
- begin
- TBA := [IntToBox(10, 10, 20, 20), IntToBox(8, 8, 22, 22), IntToBox(12, 12, 20, 20),
- IntToBox(7, 7, 21, 21), IntToBox(11, 11, 20, 20), IntToBox(9, 9, 23, 23)];
- for a := 0 to (High(TBA) - 1) do
- for b := (a + 1) to High(TBA) do
- if SimilarBoxDimensions(TBA[a], TBA[b], DIFFERENCE) then
- WriteLn('TBA[' + IntToStr(a) + '] (' + IntToStr(((TBA[a].X2 - TBA[a].X1) + 1)) + 'x' + IntToStr(((TBA[a].Y2 - TBA[a].Y1) + 1)) + ') and TBA[' + IntToStr(b) + '] (' + IntToStr(((TBA[b].X2 - TBA[b].X1) + 1)) + 'x' + IntToStr(((TBA[b].Y2 - TBA[b].Y1) + 1)) + ') are similar.');
- end.[/simba]
- [/spoiler]
- [spoiler="MergeTBA"]
- [simba]{==============================================================================]
- Explanation: Merges array of boxes (TBA) to 1 box.
- [==============================================================================}
- function MergeTBA(TBA: TBoxArray): TBox;
- var
- h, i: Integer;
- e: TBox;
- begin
- h := High(TBA);
- if (h > -1) then
- begin
- Result := IntToBox(Min(TBA[0].X1, TBA[0].X2), Min(TBA[0].Y1, TBA[0].Y2), Max(TBA[0].X1, TBA[0].X2), Max(TBA[0].Y1, TBA[0].Y2));
- if (h > 0) then
- for i := 1 to h do
- begin
- if (TBA[i].X1 < Result.X1) then
- Result.X1 := Integer(TBA[i].X1);
- if (TBA[i].X2 < Result.X1) then
- Result.X1 := Integer(TBA[i].X2);
- if (TBA[i].Y1 < Result.Y1) then
- Result.Y1 := Integer(TBA[i].Y1);
- if (TBA[i].Y2 < Result.Y1) then
- Result.Y1 := Integer(TBA[i].Y2);
- if (TBA[i].X2 > Result.X2) then
- Result.X2 := Integer(TBA[i].X2);
- if (TBA[i].X1 > Result.X2) then
- Result.X2 := Integer(TBA[i].X1);
- if (TBA[i].Y2 > Result.Y2) then
- Result.Y2 := Integer(TBA[i].Y2);
- if (TBA[i].Y1 > Result.Y2) then
- Result.Y2 := Integer(TBA[i].Y1);
- end;
- end else
- Result := e;
- end;
- begin
- WriteLn(MergeTBA([IntToBox(10, 10, 20, 20), IntToBox(5, 5, 10, 10), IntToBox(25, 25, 50, 50)]));
- end.[/simba]
- [/spoiler]
- [spoiler="BoxInTPA"]
- [simba]{==============================================================================]
- Explanation: Returns true if bx is in TPA (TPA contains all points from bx).
- [==============================================================================}
- function BoxInTPA(bx: TBox; TPA: TPointArray): Boolean;
- begin
- if ((bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2) and (Length(TPA) >= (((bx.X2 - bx.X1) + 1) * ((bx.Y2 - bx.Y1) + 1)))) then
- Result := (Length(ReturnPointsNotInTPA(TPA, bx)) = 0)
- else
- Result := False;
- end;
- begin
- if BoxInTPA(IntToBox(25, 25, 50, 50), TPAFromBox(IntToBox(0, 0, 100, 100))) then
- WriteLn('YEA!');
- if BoxInTPA(IntToBox(25, 25, 50, 50), TPAFromBox(IntToBox(26, 25, 50, 50))) then
- WriteLn('YEA!');
- end.[/simba]
- [/spoiler]
- [spoiler="TBABounds"]
- [simba]{==============================================================================]
- Explanation: Returns the bounds of TBA.
- [==============================================================================}
- function TBABounds(TBA: TBoxArray): TBox;
- var
- h, i: Integer;
- e: TBox;
- begin
- h := High(TBA);
- if (h > -1) then
- begin
- Result := TBox(TBA[0]);
- if (h < 1) then
- Exit;
- for i := 1 to h do
- begin
- if (Result.X1 > TBA[i].X1) then
- Result.X1 := Integer(TBA[i].X1);
- if (Result.Y1 > TBA[i].Y1) then
- Result.Y1 := Integer(TBA[i].Y1);
- if (Result.X2 < TBA[i].X2) then
- Result.X2 := Integer(TBA[i].X2);
- if (Result.Y2 < TBA[i].Y2) then
- Result.Y2 := Integer(TBA[i].Y2);
- end;
- end else
- Result := e;
- end;
- begin
- WriteLn(TBABounds([IntToBox(5, 5, 10, 10), IntToBox(25, 25, 50, 50)]));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAGrid"]
- [simba]{==============================================================================]
- Explanation: Returns/builds grid of boxes with parameters;
- startPoint = start point of the grid
- boxWidth, boxHeight = dimensions of all boxes
- rows, columns = count of rows and columns
- rowSpace, columnSpace = the space between points at rows and columns
- [==============================================================================}
- function TBAGrid(startPoint: TPoint; boxWidth, boxHeight, rows, columns, rowSpace, columnSpace: Integer): TBoxArray;
- var
- r, c: Integer;
- begin
- if ((rows > -1) and (columns > -1) and (boxWidth > 0) and (boxHeight > 0) and ((rows * columns) > 0)) then
- begin
- SetLength(Result, (rows * columns));
- for r := 0 to (rows - 1) do
- for c := 0 to (columns - 1) do
- Result[((r * columns) + c)] := IntToBox((startPoint.X + (c * columnSpace)), (startPoint.Y + (r * rowSpace)), ((startPoint.X + (c * columnSpace)) + (boxWidth - 1)), ((startPoint.Y + (r * rowSpace)) + (boxHeight - 1)));
- end else
- SetLength(Result, 0);
- end;
- const
- START_X = 10; START_Y = 10;
- WIDTH = 10; HEIGHT = 5;
- ROWS = 8; COLUMNS = 16;
- ROW_SPACE = (HEIGHT + 1); COLUMN_SPACE = (WIDTH + 2);
- var
- b, i: Integer;
- TPA: TPointArray;
- TBA: TBoxArray;
- begin
- DisplayDebugImgWindow(500, 500);
- TBA := TBAGrid(Point(START_X, START_Y), WIDTH, HEIGHT, ROWS, COLUMNS, ROW_SPACE, COLUMN_SPACE);
- for i := 0 to High(TBA) do
- TPA := CombineTPA(TPA, TPAFromBox(TBA[i]));
- SetLength(TBA, 0);
- b := CreateBitmap(500, 500);
- for i := 0 to High(TPA) do
- FastSetPixel(b, TPA[i].X, TPA[i].Y, 255);
- DrawBitmapDebugImg(b);
- SetLength(TPA, 0);
- FreeBitmap(b);
- end.[/simba]
- [/spoiler]
- [spoiler="TBARow"]
- [simba]{==============================================================================]
- Explanation: Returns row of boxes. Starting from startPoint,
- where rowSpace is the amount of space between each box.
- [==============================================================================}
- function TBARow(startPoint: TPoint; boxWidth, boxHeight, rows, rowSpace: Integer): TBoxArray;
- var
- i: Integer;
- begin
- if ((rows > 0) and (boxWidth > 0) and (boxHeight > 0)) then
- begin
- SetLength(Result, rows);
- for i := 0 to (rows - 1) do
- Result[i] := IntToBox(startPoint.X, (startPoint.Y + (i * rowSpace)), (startPoint.X + (boxWidth - 1)), ((startPoint.Y + (i * rowSpace)) + (boxHeight - 1)));
- end else
- SetLength(Result, 0);
- end;
- const
- START_X = 10; START_Y = 10;
- WIDTH = 10; HEIGHT = 5;
- ROWS = 50;
- ROW_SPACE = (HEIGHT + 1);
- var
- b, i: Integer;
- TPA: TPointArray;
- TBA: TBoxArray;
- begin
- DisplayDebugImgWindow(500, 500);
- TBA := TBARow(Point(START_X, START_Y), WIDTH, HEIGHT, ROWS, ROW_SPACE);
- WriteLn(ToStr(TBA));
- for i := 0 to High(TBA) do
- TPA := CombineTPA(TPA, TPAFromBox(TBA[i]));
- SetLength(TBA, 0);
- b := CreateBitmap(500, 500);
- for i := 0 to High(TPA) do
- FastSetPixel(b, TPA[i].X, TPA[i].Y, 255);
- DrawBitmapDebugImg(b);
- SetLength(TPA, 0);
- FreeBitmap(b);
- end.[/simba]
- [/spoiler]
- [spoiler="TBAColumn"]
- [simba]{==============================================================================]
- Explanation: Returns column of boxes. Starting from startPoint,
- where columnSpace is the amount of space between each box.
- [==============================================================================}
- function TBAColumn(startPoint: TPoint; boxWidth, boxHeight, columns, columnSpace: Integer): TBoxArray;
- var
- i: Integer;
- begin
- if ((columns > 0) and (boxWidth > 0) and (boxHeight > 0)) then
- begin
- SetLength(Result, columns);
- for i := 0 to (columns - 1) do
- Result[i] := IntToBox((startPoint.X + (i * columnSpace)), startPoint.Y, ((startPoint.X + (i * columnSpace)) + (boxWidth - 1)), (startPoint.Y + (boxHeight - 1)));
- end else
- SetLength(Result, 0);
- end;
- const
- START_X = 10; START_Y = 10;
- WIDTH = 10; HEIGHT = 5;
- COLUMNS = 25;
- COLUMN_SPACE = (WIDTH + 1);
- var
- b, i: Integer;
- TPA: TPointArray;
- TBA: TBoxArray;
- begin
- DisplayDebugImgWindow(500, 500);
- TBA := TBAColumn(Point(START_X, START_Y), WIDTH, HEIGHT, COLUMNS, COLUMN_SPACE);
- WriteLn(ToStr(TBA));
- for i := 0 to High(TBA) do
- TPA := CombineTPA(TPA, TPAFromBox(TBA[i]));
- SetLength(TBA, 0);
- b := CreateBitmap(500, 500);
- for i := 0 to High(TPA) do
- FastSetPixel(b, TPA[i].X, TPA[i].Y, 255);
- DrawBitmapDebugImg(b);
- SetLength(TPA, 0);
- FreeBitmap(b);
- end.[/simba]
- [/spoiler]
- [spoiler="TBACopyEx"]
- [simba]{==============================================================================]
- Explanation: Copies TBA items from pos1 to pos2.
- Supports reversed copying aswell (pos1 > pos2)!
- [==============================================================================}
- function TBACopyEx(TBA: TBoxArray; pos1, pos2: Integer): TBoxArray;
- var
- i, l: Integer;
- begin
- l := Length(TBA);
- if (l > 0) then
- begin
- if (pos1 < 0) then
- pos1 := 0;
- if (pos1 > (l - 1)) then
- pos1 := (l - 1);
- if (pos2 < 0) then
- pos2 := 0;
- if (pos2 > (l - 1)) then
- pos2 := (l - 1);
- if (pos1 <> pos2) then
- begin
- {$IFNDEF Lape}
- SetLength(Result, (IAbs(pos1 - pos2) + 1));
- {$ELSE}
- SetLength(Result, (Abs(pos1 - pos2) + 1));
- {$ENDIF}
- if (pos1 < pos2) then
- begin
- for i := pos1 to pos2 do
- Result[(i - pos1)] := TBox(TBA[i]);
- end else
- for i := pos1 downto pos2 do
- Result[(pos1 - i)] := TBox(TBA[i]);
- end else
- Result := [TBox(TBA[pos1])];
- end else
- SetLength(Result, 0);
- end;
- begin
- // Copying indexes 2=>1:
- WriteLn(ToStr(TBACopyEx([IntToBox(0, 0, 5, 5), IntToBox(1, 1, 6, 6), IntToBox(2, 2, 4, 4), IntToBox(1, 1, 3, 3)], 2, 1)));
- // Copying indexes 1=>2:
- WriteLn(ToStr(TBACopyEx([IntToBox(0, 0, 5, 5), IntToBox(1, 1, 6, 6), IntToBox(2, 2, 4, 4), IntToBox(1, 1, 3, 3)], 1, 2)));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAClone"]
- [simba]{==============================================================================]
- Explanation: Returns copy/"clone" of TBA.
- [==============================================================================}
- function TBAClone(TBA: TBoxArray): TBoxArray;
- var
- h, i: Integer;
- begin
- h := High(TBA);
- SetLength(Result, (h + 1));
- for i := 0 to h do
- Result[i] := TBox(TBA[i]);
- end;
- begin
- WriteLn(ToStr(TBAClone([IntToBox(0, 0, 5, 5), IntToBox(1, 1, 6, 6), IntToBox(2, 2, 4, 4), IntToBox(1, 1, 3, 3)])));
- end.[/simba]
- [/spoiler]
- [spoiler="TBACombine"]
- [simba]{==============================================================================]
- Explanation: Returns TBA1 and TBA2 combined together.
- [==============================================================================}
- function TBACombine(TBA1, TBA2: TBoxArray): TBoxArray;
- var
- l1, l2, i: Integer;
- begin
- l1 := Length(TBA1);
- l2 := Length(TBA2);
- SetLength(Result, (l1 + l2));
- for i := 0 to (l1 - 1) do
- Result[i] := TBox(TBA1[i]);
- for i := 0 to (l2 - 1) do
- Result[(l1 + i)] := TBox(TBA2[i]);
- end;
- begin
- WriteLn(ToStr(TBACombine([IntToBox(1, 2, 3, 4)], [IntToBox(5, 6, 7, 8)])));
- end.[/simba]
- [/spoiler]
- [spoiler="TBADelete"]
- [simba]{==============================================================================]
- Explanation: Deletes TBA item by x as the index position. Returns true with success.
- [==============================================================================}
- function TBADelete(var TBA: TBoxArray; x: Integer): Boolean;
- var
- i, h: Integer;
- begin
- h := High(TBA);
- Result := ((x < (h + 1)) and (x > -1));
- if not Result then
- Exit;
- for i := x to (h - 1) do
- TBA[i] := TBA[(i + 1)];
- SetLength(TBA, h);
- end;
- var
- TBA: TBoxArray;
- i: Integer;
- begin
- SetLength(TBA, 5);
- for i := 5 downto -1 do
- if TBADelete(TBA, i) then
- WriteLn('Deleted index ' + IntToStr(i) + ' from TBA => ' + ToStr(TBA))
- else
- WriteLn('Couldn''t delete index ' + IntToStr(i) + ' from TBA => ' + ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBARemove"]
- [simba]{==============================================================================]
- Explanation: Removes boxes from TBA, x = array of indexes.
- NOTE: DYNAMIC index deletion! Doesn't pay attention to duplicate indexes.
- Deletes indexes with the loop, so place the indexes the way you need them to be deleted. :)
- [==============================================================================}
- procedure TBARemove(var TBA: TBoxArray; x: TIntegerArray);
- var
- i, i2, h, h2: Integer;
- begin
- h := High(TBA);
- h2 := High(x);
- if ((h < 0) or (h2 < 0)) then
- Exit;
- for i2 := 0 to h2 do
- if ((x[i2] <= h) and (x[i2] > -1)) then
- begin
- for i := x[i2] to (h - 1) do
- TBA[i] := TBA[(i + 1)];
- Dec(h);
- end;
- SetLength(TBA, (h + 1));
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBARemove(TBA, [0, 1, 2]); // Without reversed indexes
- WriteLn(ToStr(TBA));
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBARemove(TBA, [2, 1, 0]); // With reversed indexes
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBASame"]
- [simba]{==============================================================================]
- Explanation: Returns true if TBA1 and TBA2 are identical.
- [==============================================================================}
- function TBASame(TBA1, TBA2: TBoxArray): Boolean;
- var
- h, i: Integer;
- begin
- Result := False;
- h := High(TBA1);
- if (h <> High(TBA2)) then
- Exit;
- for i := 0 to h do
- if ((TBA1[i].X1 <> TBA2[i].X1) or (TBA1[i].Y1 <> TBA2[i].Y1) or (TBA1[i].X2 <> TBA2[i].X2) or (TBA1[i].Y2 <> TBA2[i].Y2)) then
- Exit;
- Result := True;
- end;
- begin
- if TBASame([], []) then
- WriteLn('YEP 1!');
- if TBASame([IntToBox(0, 0, 0, 0), IntToBox(1, 2, 3, 4)], [IntToBox(0, 0, 0, 0), IntToBox(1, 2, 3, 4)]) then
- WriteLn('YEP 2!');
- if TBASame([IntToBox(0, 0, 0, 0), IntToBox(1, 2, 3, 4)], [IntToBox(0, 0, 0, 1), IntToBox(1, 2, 3, 4)]) then
- WriteLn('NOPE 1!');
- end.[/simba]
- [/spoiler]
- [spoiler="TBAInsert"]
- [simba]{==============================================================================]
- Explanation: Inserts bx to index position of TBA.
- [==============================================================================}
- procedure TBAInsert(var TBA: TBoxArray; index: Integer; bx: TBox);
- var
- i, l: Integer;
- begin
- l := Length(TBA);
- SetLength(TBA, (l + 1));
- if (index < 0) then
- index := 0;
- if (index > l) then
- index := l;
- if (l > index) then
- for i := (l - 1) downto index do
- TBA[(i + 1)] := TBA[i];
- TBA[index] := TBox(bx);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBAInsert(TBA, 4, IntToBox(4, 4, 5, 5));
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAAppend"]
- [simba]{==============================================================================]
- Explanation: Appends TBA with bx.
- [==============================================================================}
- procedure TBAAppend(var TBA: TBoxArray; bx: TBox);
- var
- aL: Integer;
- begin
- aL := (Length(TBA) + 1);
- SetLength(TBA, aL);
- TBA[(aL - 1)] := TBox(bx);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8)];
- TBAAppend(TBA, IntToBox(8, 8, 9, 9));
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/simba]
- [/spoiler]
- [spoiler="TBAAdd"]
- [simba]{==============================================================================]
- Explanation: Adds all addTBA items to TBA. Returns the highest index in the end.
- [==============================================================================}
- function TBAAdd(var TBA: TBoxArray; addTBA: TBoxArray): Integer;
- var
- h, l, i: Integer;
- begin
- h := High(addTBA);
- if (h > -1) then
- begin
- l := Length(TBA);
- SetLength(TBA, (l + (h + 1)));
- for i := 0 to h do
- TBA[(i + l)] := TBox(addTBA[i]);
- end;
- Result := High(TBA);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6)];
- TBAAdd(TBA, [IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)]);
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAPlant"]
- [simba]{==============================================================================]
- Explanation: Plants/places bxs to index position in TBA.
- Like TBAInsert(), with an exception that this inserts array of boxes.
- Returns the highest index from TBA in the end.
- [==============================================================================}
- function TBAPlant(var TBA: TBoxArray; index: Integer; bxs: TBoxArray): Integer;
- var
- i, l, h: Integer;
- begin
- h := High(bxs);
- if (h > -1) then
- begin
- l := Length(TBA);
- SetLength(TBA, (l + (h + 1)));
- if (index < 0) then
- index := 0;
- if (index > l) then
- index := l;
- for i := (l + (h + 1) - 1) downto (index + (h + 1)) do
- TBA[i] := TBA[(i - (h + 1))];
- for i := 0 to h do
- TBA[(i + index)] := TBox(bxs[i]);
- end;
- Result := High(TBA);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBAPlant(TBA, 3, [IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6)]);
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAUnique"]
- [simba]{==============================================================================]
- Explanation: Removes any and all duplicates from TBA.
- [==============================================================================}
- procedure TBAUnique(var TBA: TBoxArray);
- var
- h, h2, i, i2, i3, d: Integer;
- begin
- h := High(TBA);
- if (h < 1) then
- Exit;
- for i := (h - d) downto 1 do
- for i2 := (i - 1) downto 0 do
- if ((TBA[i].X1 = TBA[i2].X1) and (TBA[i].Y1 = TBA[i2].Y1) and (TBA[i].X2 = TBA[i2].X2) and (TBA[i].Y2 = TBA[i2].Y2)) then
- begin
- h2 := High(TBA);
- for i3 := i to (h2 - 1) do
- TBA[i3] := TBA[(i3 + 1)];
- SetLength(TBA, h2);
- Inc(d);
- Break;
- end;
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3), IntToBox(0, 0, 1, 1),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(2, 2, 3, 3), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBAUnique(TBA);
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBARandomizeEx"]
- [simba]{==============================================================================]
- Explanation: Randomizes the TBA.
- With higher shuffles you get "stronger" randomization..
- [==============================================================================}
- procedure TBARandomizeEx(var TBA: TBoxArray; shuffles: Integer);
- var
- i, l, s: integer;
- begin
- l := Length(TBA);
- for s := 0 to shuffles do
- for i := 0 to (l - 1) do
- Swap(TBA[Random(l)], TBA[Random(l)]);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBARandomizeEx(TBA, (Random(2) + 1));
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBARandomize"]
- [simba]{==============================================================================]
- Explanation: Randomizes the TBA.
- [==============================================================================}
- procedure TBARandomize(var TBA: TBoxArray);
- var
- i, l: integer;
- begin
- l := Length(TBA);
- for i := 0 to (l - 1) do
- Swap(TBA[Random(l)], TBA[Random(l)]);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBARandomize(TBA);
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAContains"]
- [simba]{==============================================================================]
- Explanation: Returns true if TBA contains bx.
- [==============================================================================}
- function TBAContains(TBA: TBoxArray; bx: TBox): Boolean;
- var
- i, h: Integer;
- begin
- h := High(TBA);
- for i := 0 to h do
- begin
- Result := ((bx.X1 = TBA[i].X1) and (bx.Y1 = TBA[i].Y1) and (bx.X2 = TBA[i].X2) and (bx.Y2 = TBA[i].Y2));
- if Result then
- Exit;
- end;
- Result := False;
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- if TBAContains(TBA, IntToBox(7, 7, 8, 8)) then
- WriteLn('YUP!');
- if TBAContains(TBA, IntToBox(1, 2, 3, 4)) then
- WriteLn('The heck?!');
- end.[/simba]
- [/spoiler]
- [spoiler="TBAPositions"]
- [simba]{==============================================================================]
- Explanation: Returns all the positions in TBA where bx is found/matched.
- [==============================================================================}
- function TBAPositions(TBA: TBoxArray; bx: TBox): TIntegerArray;
- var
- i, h, r: Integer;
- begin
- h := High(TBA);
- if (h > -1) then
- begin
- SetLength(Result, (h + 1));
- for i := 0 to h do
- if ((bx.X1 = TBA[i].X1) and (bx.Y1 = TBA[i].Y1) and (bx.X2 = TBA[i].X2) and (bx.Y2 = TBA[i].Y2)) then
- begin
- Result[r] := i;
- Inc(r);
- end;
- end;
- SetLength(Result, r);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9),
- IntToBox(0, 0, 1, 1)];
- WriteLn(ToStr(TBAPositions(TBA, IntToBox(0, 0, 1, 1))));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAGet"]
- [simba]{==============================================================================]
- Explanation: Returns item[s] from TBA by IDs. Ignores invalid ID's.
- [==============================================================================}
- function TBAGet(TBA: TBoxArray; IDs: TIntegerArray): TBoxArray;
- var
- i, h, h2, rC: Integer;
- begin
- h := High(TBA);
- h2 := High(IDs);
- if (h2 > -1) then
- begin
- SetLength(Result, (h2 + 1));
- for i := 0 to h2 do
- if ((IDs[i] <= h) and (IDs[i] > -1)) then
- begin
- Result[rC] := TBox(TBA[IDs[i]]);
- Inc(rC);
- end;
- end;
- SetLength(Result, rC);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- WriteLn(ToStr(TBAGet(TBA, [-1342, 0, 9949993, 1, -2342, 2, 45454, 3])));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAMove"]
- [simba]{==============================================================================]
- Explanation: Moves oldIndex to newIndex in TBA. Returns true, if movement was succesfully done!
- [==============================================================================}
- function TBAMove(var TBA: TBoxArray; oldIndex, newIndex: Integer): Boolean;
- var
- h, i: Integer;
- begin
- h := High(TBA);
- Result := ((h > 0) and (oldIndex <> newIndex) and InRange(oldIndex, 0, h) and InRange(newIndex, 0, h));
- if Result then
- if (oldIndex > newIndex) then
- begin
- for i := oldIndex downto (newIndex + 1) do
- Swap(TBA[i], TBA[(i - 1)]);
- end else
- for i := oldIndex to (newIndex - 1) do
- Swap(TBA[i], TBA[(i + 1)]);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(6, 6, 7, 7), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- TBAMove(TBA, 1, 6);
- WriteLn(ToStr(TBA));
- end.[/simba]
- [/spoiler]
- [spoiler="TBAToParts"]
- [simba]type
- TPartitionMethod = (pm_PartSize, pm_PartAmount);
- function TBAToParts(TBA: TBoxArray; method: TPartitionMethod; x: Integer): array of TBoxArray;
- {==============================================================================]
- Explanation: Breaks TBA to parts (TBA => ATBA). Contains 2 methods:
- -pm_PartSize (Breaks TBA to ATBA by size of the parts) [x = size]
- -pm_PartAmount (Breaks TBA to ATBA by amount of the parts) [x = amount]
- [==============================================================================}
- var
- a, e, h, h2, i, i2, p, l, z: Integer;
- f: Boolean;
- begin
- h := High(TBA);
- if ((h > -1) and (x > 0)) then
- begin
- case method of
- pm_PartSize:
- if (x <= h) then
- begin
- Inc(h);
- p := (h div x);
- if ((p * x) < h) then
- Inc(p);
- SetLength(Result, p);
- for i := 0 to (p - 1) do
- for i2 := 0 to (x - 1) do
- begin
- SetLength(Result[i], x);
- if (a < h) then
- begin
- Result[i][i2] := TBox(TBA[a]);
- Inc(a);
- end else
- begin
- SetLength(Result[i], i2);
- Exit;
- end;
- end;
- end else
- f := True;
- pm_PartAmount:
- if (h > -1) then
- begin
- if (h < (x - 1)) then
- x := (h + 1);
- p := Floor((h + 1) / x);
- if (p = 0) then
- p := 1;
- e := ((h + 1) - (p * x));
- if (e >= (h + 1)) then
- e := 0;
- SetLength(Result, x);
- for i := 0 to (x - 1) do
- begin
- if ((e >= (i + 1)) and (e > 0)) then
- SetLength(Result[i], (p + 1))
- else
- if (i <= h) then
- SetLength(Result[i], p);
- h2 := High(Result[i]);
- for i2 := 0 to h2 do
- begin
- Result[i][i2] := TBox(TBA[a]);
- Inc(a);
- end;
- end;
- end else
- f := True;
- end;
- if f then
- begin
- SetLength(Result, 1);
- l := Length(TBA);
- SetLength(Result[0], l);
- for z := 0 to (l - 1) do
- Result[0][z] := TBox(TBA[z]);
- end;
- end else
- SetLength(Result, 0);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3),
- IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6),
- IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- WriteLn('TBAToParts(TBA, pm_PartSize, 4): ' + ToStr(TBAToParts(TBA, pm_PartSize, 4)));
- WriteLn('TBAToParts(TBA, pm_PartAmount, 4): ' + ToStr(TBAToParts(TBA, pm_PartAmount, 4)));
- end.[/simba]
- [/spoiler]
- [spoiler="TBACenterPointsEx"]
- [simba]{==============================================================================]
- Explanation: Returns center points from all TBA indexes.
- Adds randomness to the points, if you set XOffsetRadius or/and YOffsetRadius HIGHER than 0.
- [==============================================================================}
- function TBACenterPointsEx(TBA: TBoxArray; XOffsetRadius, YOffsetRadius: Integer): TPointArray;
- var
- h, i: Integer;
- begin
- h := High(TBA);
- if (h > -1) then
- begin
- SetLength(Result, (h + 1));
- if ((XOffsetRadius > 0) or (YOffsetRadius > 0)) then
- begin
- if (XOffsetRadius < 0) then
- XOffsetRadius := 0;
- if (YOffsetRadius < 0) then
- YOffsetRadius := 0;
- for i := 0 to h do
- begin
- if ((TBA[i].X1 <= TBA[i].X2) and (TBA[i].Y1 <= TBA[i].Y2)) then
- Result[i] := Point(Round(TBA[i].X1 + ((TBA[i].X2 - TBA[i].X1) div 2)), Round(TBA[i].Y1 + ((TBA[i].Y2 - TBA[i].Y1) div 2)))
- else
- Result[i] := Point(0, 0);
- Result[i].X := (Result[i].X + RandomRange(-XOffsetRadius, (XOffsetRadius + 1)));
- Result[i].Y := (Result[i].Y + RandomRange(-YOffsetRadius, (YOffsetRadius + 1)));
- end;
- end else
- for i := 0 to h do
- if ((TBA[i].X1 <= TBA[i].X2) and (TBA[i].Y1 <= TBA[i].Y2)) then
- Result[i] := Point(Round(TBA[i].X1 + ((TBA[i].X2 - TBA[i].X1) div 2)), Round(TBA[i].Y1 + ((TBA[i].Y2 - TBA[i].Y1) div 2)))
- else
- Result[i] := Point(0, 0);
- end else
- SetLength(Result, 0);
- end;
- var
- r: Integer;
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 49, 49), IntToBox(100, 100, 199, 199), IntToBox(250, 250, 499, 499)];
- for r := 0 to 5 do
- WriteLn('TBACenterPointsEx(TBA, ' + IntToStr(r) + ', ' + IntToStr(r) + '): ' + ToStr(TBACenterPointsEx(TBA, r, r)));
- end.[/simba]
- [/spoiler]
- [spoiler="TBACenterPoints"]
- [simba]{==============================================================================]
- Explanation: Returns center points from all TBA indexes.
- Results will be without randomness. So, "perfect" center points!
- [==============================================================================}
- function TBACenterPoints(TBA: TBoxArray): TPointArray;
- var
- h, i: Integer;
- begin
- h := High(TBA);
- if (h > -1) then
- begin
- SetLength(Result, (h + 1));
- for i := 0 to h do
- if ((TBA[i].X1 <= TBA[i].X2) and (TBA[i].Y1 <= TBA[i].Y2)) then
- Result[i] := Point(Round(TBA[i].X1 + ((TBA[i].X2 - TBA[i].X1) div 2)), Round(TBA[i].Y1 + ((TBA[i].Y2 - TBA[i].Y1) div 2)))
- else
- Result[i] := Point(0, 0);
- end else
- SetLength(Result, 0);
- end;
- var
- TBA: TBoxArray;
- begin
- TBA := [IntToBox(0, 0, 49, 49), IntToBox(100, 100, 199, 199), IntToBox(250, 250, 499, 499)];
- WriteLn('TBACenterPoints(TBA): ' + ToStr(TBACenterPoints(TBA)));
- end.[/simba]
- [/spoiler]
- [spoiler="ATBAMerge"]
- [simba]function ATBAMerge(ATBA: array of TBoxArray): TBoxArray;
- var
- i, i2, h, h2, r: Integer;
- begin
- h := High(ATBA);
- if (h > -1) then
- begin
- for i := 0 to h do
- IncEx(r, (High(ATBA[i]) + 1));
- SetLength(Result, r);
- r := 0;
- for i := 0 to h do
- begin
- h2 := High(ATBA[i]);
- for i2 := 0 to h2 do
- begin
- Result[r] := TBox(ATBA[i][i2]);
- Inc(r);
- end;
- end;
- end else
- SetLength(Result, 0);
- end;
- var
- ATBA: array of TBoxArray;
- begin
- SetLength(ATBA, 3);
- ATBA[0] := [IntToBox(0, 0, 1, 1), IntToBox(1, 1, 2, 2), IntToBox(2, 2, 3, 3)];
- ATBA[1] := [IntToBox(3, 3, 4, 4), IntToBox(4, 4, 5, 5), IntToBox(5, 5, 6, 6)];
- ATBA[2] := [IntToBox(6, 6, 7, 7), IntToBox(7, 7, 8, 8), IntToBox(8, 8, 9, 9)];
- WriteLn(ToStr(ATBAMerge(ATBA)));
- SetLength(ATBA, 0);
- end.[/simba]
- [/spoiler]
- Going to add more stuff soon. :stirthepot:
- ..oh and, just like for the String Handling Commands:
- Feel free to use/take/improve/anything - it's all open-source!
- Giving credit is always appreciated, but not really necessary for me. :)
- Have fun!
- -Jani
Advertisement
Add Comment
Please, Sign In to add comment