Skip to content

Commit

Permalink
Add polygon type
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Jan 7, 2025
1 parent b46dbb5 commit d619b1c
Show file tree
Hide file tree
Showing 42 changed files with 995 additions and 1,367 deletions.
2 changes: 1 addition & 1 deletion Source/ide/codetools/simba.ide_codetools_includes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface
uses
Classes, SysUtils,
simba.base, simba.threading,
simba.ide_codetools_base, simba.ide_codetools_paslexer, simba.ide_codetools_parser;
simba.ide_codetools_paslexer, simba.ide_codetools_parser;

const
PurgeThreshold = 35; // If cache miss reaches of a include reaches this, remove the cache
Expand Down
2 changes: 1 addition & 1 deletion Source/ide/codetools/simba.ide_codetools_keywords.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface

uses
Classes, SysUtils,
simba.base, simba.ide_codetools_base, simba.ide_codetools_parser, simba.ide_initialization;
simba.base, simba.ide_codetools_parser, simba.ide_initialization;

function GetKeywords: TDeclarationArray;

Expand Down
2 changes: 1 addition & 1 deletion Source/ide/codetools/simba.ide_codetools_pasparser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface

uses
SysUtils, Classes,
simba.ide_codetools_base, simba.ide_codetools_paslexer;
simba.ide_codetools_paslexer;

type
TPasParser = class(TObject)
Expand Down
2 changes: 1 addition & 1 deletion Source/ide/simba.form_functionlist.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface

uses
Classes, SysUtils, Forms, Controls, ComCtrls, ExtCtrls, Menus, StrUtils,
simba.base, simba.ide_codetools_base, simba.ide_codetools_parser, simba.ide_codetools_insight,
simba.base, simba.ide_codetools_parser, simba.ide_codetools_insight,
simba.component_treeview, simba.container_dict;

type
Expand Down
2 changes: 1 addition & 1 deletion Source/ide/simba.ide_editor_docgenerator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TSimbaEditorPlugin_DocGenerator = class(TLazSynEditPlugin)
implementation

uses
simba.ide_codetools_base, simba.ide_codetools_parser, simba.settings,
simba.ide_codetools_parser, simba.settings,
simba.dialog;

procedure TSimbaEditorPlugin_DocGenerator.DoEditorAdded(Value: TCustomSynEdit);
Expand Down
4 changes: 2 additions & 2 deletions Source/script/imports/simba.import_base.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ implementation
uses
Graphics, Variants,
simba.nativeinterface, simba.env, simba.baseclass, simba.vartype_ordarray,
simba.vartype_string, simba.vartype_pointarray, simba.vartype_matrix,
simba.vartype_box, simba.array_algorithm;
simba.vartype_string, simba.vartype_pointarray,
simba.vartype_box;

(*
Base
Expand Down
77 changes: 3 additions & 74 deletions Source/script/imports/simba.import_box.pas
Original file line number Diff line number Diff line change
Expand Up @@ -147,70 +147,18 @@ procedure _LapeBox_Expand4(const Params: PParamArray; const Result: Pointer); LA
PBox(Result)^ := PBox(Params^[0])^.Expand(PInteger(Params^[1])^, PInteger(Params^[2])^, PBox(Params^[3])^);
end;

(*
TBox.Extract
------------
```
function TBox.Extract(Points: TPointArray): TPointArray;
```
Returns all points that *are inside* the box.
*)
procedure _LapeBox_Extract(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPointArray(Result)^ := PBox(Params^[0])^.Extract(PPointArray(Params^[1])^);
end;

(*
TBox.Exclude
------------
```
function TBox.Exclude(Points: TPointArray): TPointArray;
```
Returns all points that are *not inside* the box.
*)
procedure _LapeBox_Exclude(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPointArray(Result)^ := PBox(Params^[0])^.Exclude(PPointArray(Params^[1])^);
end;

(*
TBox.Contains
-------------
```
function TBox.Contains(Other: TBox): Boolean;
function TBox.Contains(Point: TPoint): Boolean;
```
*)
procedure _LapeBox_Contains1(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PBoolean(Result)^ := PBox(Params^[0])^.Contains(PBox(Params^[1])^);
end;

(*
TBox.Contains
-------------
```
function TBox.Contains(Other: TPoint): Boolean;
```
*)
procedure _LapeBox_Contains2(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
procedure _LapeBox_Contains(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PBoolean(Result)^ := PBox(Params^[0])^.Contains(PPoint(Params^[1])^);
end;

(*
TBox.Contains
-------------
```
function TBox.Contains(Other: TQuad): Boolean;
```
*)
procedure _LapeBox_Contains3(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PBoolean(Result)^ := PBox(Params^[0])^.Contains(PQuad(Params^[1])^);
end;

(*
TBox.Partition
--------------
Expand Down Expand Up @@ -355,20 +303,6 @@ procedure _LapeBox_Corners(const Params: PParamArray; const Result: Pointer); LA
PPointArray(Result)^ := PBox(Params^[0])^.Corners();
end;

(*
TBox.ToQuad
-----------
```
function TBox.ToQuad: TQuad;
```
Converts the TBox to a TQuad type.
*)
procedure _LapeBox_ToQuad(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PQuad(Result)^ := PBox(Params^[0])^.ToQuad();
end;

(*
TBox.RandomPoint
----------------
Expand Down Expand Up @@ -665,16 +599,11 @@ procedure ImportBox(Script: TSimbaScript);
addGlobalFunc('function TBox.Expand(SizeMod: Integer; MaxBounds: TBox): TBox; overload;', @_LapeBox_Expand3);
addGlobalFunc('function TBox.Expand(WidMod, HeiMod: Integer): TBox; overload;', @_LapeBox_Expand2);
addGlobalFunc('function TBox.Expand(WidMod, HeiMod: Integer; MaxBounds: TBox): TBox; overload;', @_LapeBox_Expand4);
addGlobalFunc('function TBox.Extract(Points: TPointArray): TPointArray', @_LapeBox_Extract);
addGlobalFunc('function TBox.Exclude(Points: TPointArray): TPointArray', @_LapeBox_Exclude);
addGlobalFunc('function TBox.Contains(Other: TBox): Boolean; overload;', @_LapeBox_Contains1);
addGlobalFunc('function TBox.Contains(Other: TPoint): Boolean; overload;', @_LapeBox_Contains2);
addGlobalFunc('function TBox.Contains(Other: TQuad): Boolean; overload;', @_LapeBox_Contains3);
addGlobalFunc('function TBox.Contains(Point: TPoint): Boolean;', @_LapeBox_Contains);
addGlobalFunc('function TBox.Partition(Rows, Cols: Integer): TBoxArray;', @_LapeBox_Partition);
addGlobalFunc('function TBox.Offset(P: TPoint): TBox; overload;', @_LapeBox_Offset1);
addGlobalFunc('function TBox.Combine(Other: TBox): TBox;', @_LapeBox_Combine);
addGlobalFunc('function TBox.Invert(Space: TBox): TBoxArray;', @_LapeBox_Invert);
addGlobalFunc('function TBox.ToQuad: TQuad;', @_LapeBox_ToQuad);

addGlobalFunc('function TBox.NearestEdge(P: TPoint): TPoint;', @_LapeBox_NearestEdge);
addGlobalFunc('function TBox.Intersect(P: TPoint): TPoint;', @_LapeBox_Intersect);
Expand Down
57 changes: 0 additions & 57 deletions Source/script/imports/simba.import_circle.pas
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,6 @@ procedure _LapeCircle_CreateFromPoints(const Params: PParamArray; const Result:
PCircle(Result)^ := TCircle.CreateFromPoints(PPointArray(Params^[0])^);
end;


(*
TCircle.Edge
------------
```
function TCircle.Edge: TPointArray;
```
*)
procedure _LapeCircle_Edge_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPointArray(Result)^ := PCircle(Params^[0])^.Edge;
end;

(*
TCircle.Filled
--------------
```
function TCircle.Filled: TPointArray;
```
*)
procedure _LapeCircle_Filled_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPointArray(Result)^ := PCircle(Params^[0])^.Filled;
end;

(*
TCircle.Bounds
--------------
Expand Down Expand Up @@ -222,34 +197,6 @@ procedure _LapeCircle_Offset(const Params: PParamArray; const Result: Pointer);
PCircle(Result)^ := PCircle(Params^[0])^.Offset(PPoint(Params^[1])^);
end;

(*
TCircle.Extract
---------------
```
function TCircle.Extract(Points: TPointArray): TPointArray;
```
Returns the points that **are** in the circle.
*)
procedure _LapeCircle_Extract(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPointArray(Result)^ := PCircle(Params^[0])^.Extract(PPointArray(Params^[1])^);
end;

(*
TCircle.Exclude
---------------
```
function TCircle.Exclude(Points: TPointArray): TPointArray;
```
Returns the points that are not inside the circle.
*)
procedure _LapeCircle_Exclude(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPointArray(Result)^ := PCircle(Params^[0])^.Exclude(PPointArray(Params^[1])^);
end;

(*
in
--
Expand Down Expand Up @@ -281,15 +228,11 @@ procedure ImportCircle(Script: TSimbaScript);
addGlobalFunc('function TCircle.Circularity(TPA: TPointArray): Double', @_LapeCircle_Circularity);
addGlobalFunc('function TCircle.Expand(Amount: Integer): TCircle', @_LapeCircle_Expand);
addGlobalFunc('function TCircle.Offset(P: TPoint): TCircle', @_LapeCircle_Offset);
addGlobalFunc('function TCircle.Extract(Points: TPointArray): TPointArray', @_LapeCircle_Extract);
addGlobalFunc('function TCircle.Exclude(Points: TPointArray): TPointArray', @_LapeCircle_Exclude);

addProperty('TCircle', 'Circumference', 'Double', @_LapeCircle_Circumference_Read);
addProperty('TCircle', 'Area', 'Double', @_LapeCircle_Area_Read);
addProperty('TCircle', 'Center', 'TPoint', @_LapeCircle_Center_Read);
addProperty('TCircle', 'Bounds', 'TBox', @_LapeCircle_Bounds_Read);
addProperty('TCircle', 'Edge', 'TPointArray', @_LapeCircle_Edge_Read);
addProperty('TCircle', 'Filled', 'TPointArray', @_LapeCircle_Filled_Read);

addGlobalFunc('operator in(Left: TPoint; Right: TCircle): Boolean;', @_LapePoint_IN_Cicle);

Expand Down
3 changes: 2 additions & 1 deletion Source/script/imports/simba.import_externalcanvas.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ implementation

uses
lptypes,
simba.image, simba.image_textdrawer, simba.externalcanvas;
simba.image, simba.image_textdrawer, simba.externalcanvas,
simba.vartype_quad;

type
PSimbaExternalCanvas = ^TSimbaExternalCanvas;
Expand Down
27 changes: 14 additions & 13 deletions Source/script/imports/simba.import_image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ implementation
uses
Graphics,
lptypes,
simba.image, simba.image_textdrawer, simba.colormath, simba.dtm;
simba.image, simba.image_textdrawer, simba.colormath,
simba.vartype_polygon, simba.vartype_quad, simba.vartype_circle;

type
PBitmap = ^TBitmap;
Expand Down Expand Up @@ -1038,36 +1039,36 @@ procedure _LapeImage_DrawBoxInverted(const Params: PParamArray); LAPE_WRAPPER_CA
TImage.DrawPolygon
------------------
```
procedure TImage.DrawPolygon(Points: TPointArray);
procedure TImage.DrawPolygon(Points: TPolygon);
```
*)
procedure _LapeImage_DrawPolygon(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawPolygon(PPointArray(Params^[1])^);
PSimbaImage(Params^[0])^.DrawPolygon(PPolygon(Params^[1])^);
end;

(*
TImage.DrawPolygonFilled
------------------------
```
procedure TImage.DrawPolygonFilled(Points: TPointArray);
procedure TImage.DrawPolygonFilled(Points: TPolygon);
```
*)
procedure _LapeImage_DrawPolygonFilled(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawPolygonFilled(PPointArray(Params^[1])^);
PSimbaImage(Params^[0])^.DrawPolygonFilled(PPolygon(Params^[1])^);
end;

(*
TImage.DrawPolygonInverted
--------------------------
```
procedure TImage.DrawPolygonInverted(Points: TPointArray);
procedure TImage.DrawPolygonInverted(Points: TPolygon);
```
*)
procedure _LapeImage_DrawPolygonInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawPolygonInverted(PPointArray(Params^[1])^);
PSimbaImage(Params^[0])^.DrawPolygonInverted(PPolygon(Params^[1])^);
end;

(*
Expand Down Expand Up @@ -1231,12 +1232,12 @@ procedure _LapeImage_DrawBoxArray(const Params: PParamArray); LAPE_WRAPPER_CALLI
TImage.DrawPolygonArray
-----------------------
```
procedure TImage.DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean);
procedure TImage.DrawPolygonArray(Polygons: TPolygonArray; Filled: Boolean);
```
*)
procedure _LapeImage_DrawPolygonArray(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawPolygonArray(P2DPointArray(Params^[1])^, PBoolean(Params^[2])^);
PSimbaImage(Params^[0])^.DrawPolygonArray(PPolygonArray(Params^[1])^, PBoolean(Params^[2])^);
end;

(*
Expand Down Expand Up @@ -1922,9 +1923,9 @@ procedure ImportSimbaImage(Script: TSimbaScript);
addGlobalFunc('procedure TImage.DrawBoxFilled(B: TBox);', @_LapeImage_DrawBoxFilled);
addGlobalFunc('procedure TImage.DrawBoxInverted(B: TBox);', @_LapeImage_DrawBoxInverted);

addGlobalFunc('procedure TImage.DrawPolygon(Points: TPointArray);', @_LapeImage_DrawPolygon);
addGlobalFunc('procedure TImage.DrawPolygonFilled(Points: TPointArray);', @_LapeImage_DrawPolygonFilled);
addGlobalFunc('procedure TImage.DrawPolygonInverted(Points: TPointArray);', @_LapeImage_DrawPolygonInverted);
addGlobalFunc('procedure TImage.DrawPolygon(Points: TPolygon);', @_LapeImage_DrawPolygon);
addGlobalFunc('procedure TImage.DrawPolygonFilled(Points: TPolygon);', @_LapeImage_DrawPolygonFilled);
addGlobalFunc('procedure TImage.DrawPolygonInverted(Points: TPolygon);', @_LapeImage_DrawPolygonInverted);

addGlobalFunc('procedure TImage.DrawQuad(Quad: TQuad);', @_LapeImage_DrawQuad);
addGlobalFunc('procedure TImage.DrawQuadFilled(Quad: TQuad);', @_LapeImage_DrawQuadFilled);
Expand All @@ -1945,7 +1946,7 @@ procedure ImportSimbaImage(Script: TSimbaScript);

addGlobalFunc('procedure TImage.DrawQuadArray(Quads: TQuadArray; Filled: Boolean);', @_LapeImage_DrawQuadArray);
addGlobalFunc('procedure TImage.DrawBoxArray(Boxes: TBoxArray; Filled: Boolean);', @_LapeImage_DrawBoxArray);
addGlobalFunc('procedure TImage.DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean);', @_LapeImage_DrawPolygonArray);
addGlobalFunc('procedure TImage.DrawPolygonArray(Polygons: TPolygonArray; Filled: Boolean);', @_LapeImage_DrawPolygonArray);
addGlobalFunc('procedure TImage.DrawCircleArray(Centers: TPointArray; Radius: Integer; Filled: Boolean);', @_LapeImage_DrawCircleArray1);
addGlobalFunc('procedure TImage.DrawCrossArray(Points: TPointArray; Radius: Integer);', @_LapeImage_DrawCrossArray);

Expand Down
3 changes: 2 additions & 1 deletion Source/script/imports/simba.import_imagebox.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ implementation
simba.component_imagebox, simba.component_imageboxcanvas,
simba.image, simba.image_textdrawer,
simba.dtm, simba.colormath,
simba.target;
simba.target,
simba.vartype_quad;

type
PSimbaTarget = ^TSimbaTarget;
Expand Down
Loading

0 comments on commit d619b1c

Please sign in to comment.