Skip to content

Commit

Permalink
use TCircle for TSimbaImage.DrawCircle
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Sep 19, 2023
1 parent d0f921c commit 71a30c5
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 67 deletions.
1 change: 1 addition & 0 deletions Source/script/imports/simba/simba.import_circle.pas
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ procedure ImportCircle(Compiler: TSimbaScript_Compiler);
ImportingSection := 'TCircle';

addGlobalType('record Center: TPoint; Radius: Integer; end;', 'TCircle');
addGlobalType('array of TCircle;', 'TCircleArray');

addGlobalFunc('function TCircle.Create(ACenter: TPoint; ARadius: Integer): TCircle; static; overload', @_LapeCircle_Create);
addGlobalFunc('function TCircle.CreateFromPoints(Points: TPointArray): TCircle; static; overload', @_LapeCircle_CreateFromPoints);
Expand Down
75 changes: 70 additions & 5 deletions Source/script/imports/simba/simba.import_debugimage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ implementation
> procedure Show(Quad: TQuad; Filled: Boolean = False);
*)

(*
Show
~~~~
> procedure Show(Circles: TCircleArray; Filled: Boolean = False);
*)

(*
Show
~~~~
> procedure Show(Circle: TCircle; Filled: Boolean = False);
*)

(*
Show
~~~~
Expand Down Expand Up @@ -97,19 +109,25 @@ implementation
(*
ShowOnClient
~~~~~~~~~~~~
> procedure ShowOnClient(TPA: TPointArray; Color: Integer = $0000FF);
> procedure ShowOnClient(Circles: TCircleArray; Filled: Boolean = False);
*)

(*
ShowOnClient
~~~~~~~~~~~~
> procedure ShowOnClient(ATPA: T2DPointArray);
> procedure ShowOnClient(Circle: TCircle; Filled: Boolean = False);
*)

(*
Show
~~~~
> procedure Show(Bitmap: TSimbaImage; EnsureVisible: Boolean = True);
ShowOnClient
~~~~~~~~~~~~
> procedure ShowOnClient(TPA: TPointArray; Color: Integer = $0000FF);
*)

(*
ShowOnClient
~~~~~~~~~~~~
> procedure ShowOnClient(ATPA: T2DPointArray);
*)

(*
Expand Down Expand Up @@ -309,6 +327,33 @@ procedure ImportDebugImage(Compiler: TSimbaScript_Compiler);
'end;'
]);

addGlobalFunc(
'procedure Show(Circles: TCircleArray; Filled: Boolean = False); overload;', [
'var',
' Boxes: TBoxArray;',
' Circle: TCircle;',
'begin',
' for Circle in Circles do',
' Boxes += Circle.Bounds();',
'',
' with Boxes.Merge() do',
' with TImage.Create(X1+X2+1, Y1+Y2+1) do',
' try',
' DrawCircleArray(Circles, Filled);',
' Show();',
' finally',
' Free();',
' end;',
'end;'
]);

addGlobalFunc(
'procedure Show(Circle: TCircle; Filled: Boolean = False); overload;', [
'begin',
' Show(TCircleArray([Circle]), Filled);',
'end;'
]);

addGlobalFunc(
'procedure ShowOnClient(Quads: TQuadArray; Filled: Boolean = False); overload;', [
'begin',
Expand Down Expand Up @@ -349,6 +394,26 @@ procedure ImportDebugImage(Compiler: TSimbaScript_Compiler);
'end;'
]);

addGlobalFunc(
'procedure ShowOnClient(Circles: TCircleArray; Filled: Boolean = False); overload;', [
'begin',
' with TImage.CreateFromTarget() do',
' try',
' DrawCircleArray(Circles, Filled);',
' Show();',
' finally',
' Free();',
' end;',
'end;'
]);

addGlobalFunc(
'procedure ShowOnClient(Circle: TCircle; Filled: Boolean = False); overload;', [
'begin',
' ShowOnClient(TCircleArray([Circle]), Filled);',
'end;'
]);

addGlobalFunc(
'procedure ShowOnClient(TPA: TPointArray; Color: Integer = $0000FF); overload;', [
'begin',
Expand Down
26 changes: 13 additions & 13 deletions Source/script/imports/simbaclasses/simba.import_class_image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ implementation
uses
Graphics,
lptypes,
simba.image;
simba.image, simba.circle;

type
PBitmap = ^TBitmap;
Expand Down Expand Up @@ -612,31 +612,31 @@ procedure _LapeImage_DrawPolygonInverted(const Params: PParamArray); LAPE_WRAPPE
(*
TImage.DrawCircle
~~~~~~~~~~~~~~~~~
> procedure TImage.DrawCircle(ACenter: TPoint; Radius: Integer; Color: TColor);
> procedure TImage.DrawCircle(Circle: TCircle; Color: TColor);
*)
procedure _LapeImage_DrawCircle(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawCircle(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^);
PSimbaImage(Params^[0])^.DrawCircle(PCircle(Params^[1])^, PColor(Params^[2])^);
end;

(*
TImage.DrawCircleFilled
~~~~~~~~~~~~~~~~~~~~~~~
> procedure TImage.DrawCircleFilled(ACenter: TPoint; Radius: Integer; Color: TColor);
> procedure TImage.DrawCircleFilled(Circle: TCircle; Color: TColor);
*)
procedure _LapeImage_DrawCircleFilled(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawCircleFilled(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^);
PSimbaImage(Params^[0])^.DrawCircleFilled(PCircle(Params^[1])^, PColor(Params^[2])^);
end;

(*
TImage.DrawCircleInverted
~~~~~~~~~~~~~~~~~~~~~~~~~
> procedure TImage.DrawCircleInverted(ACenter: TPoint; Radius: Integer; Color: TColor);
> procedure TImage.DrawCircleInverted(Circle: TCircle; Color: TColor);
*)
procedure _LapeImage_DrawCircleInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawCircleInverted(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^);
PSimbaImage(Params^[0])^.DrawCircleInverted(PCircle(Params^[1])^, PColor(Params^[2])^);
end;

(*
Expand Down Expand Up @@ -732,11 +732,11 @@ procedure _LapeImage_DrawPolygonArray(const Params: PParamArray); LAPE_WRAPPER_C
(*
TImage.DrawCircleArray
~~~~~~~~~~~~~~~~~~~~~~
> procedure TImage.DrawCircleArray(Points: TPointArray; Radius: Integer; Filled: Boolean; Color: TColor = -1);
> procedure TImage.DrawCircleArray(Circles: TCircleArray; Filled: Boolean; Color: TColor = -1);
*)
procedure _LapeImage_DrawCircleArray(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawCircleArray(PPointArray(Params^[1])^, PInteger(Params^[2])^, PBoolean(Params^[3])^, PColor(Params^[4])^);
PSimbaImage(Params^[0])^.DrawCircleArray(PCircleArray(Params^[1])^, PBoolean(Params^[2])^, PColor(Params^[3])^);
end;

(*
Expand Down Expand Up @@ -1326,9 +1326,9 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('procedure TImage.DrawPolygonFilled(Points: TPointArray; Color: TColor);', @_LapeImage_DrawPolygonFilled);
addGlobalFunc('procedure TImage.DrawPolygonInverted(Points: TPointArray; Color: TColor);', @_LapeImage_DrawPolygonInverted);

addGlobalFunc('procedure TImage.DrawCircle(ACenter: TPoint; Radius: Integer; Color: TColor);', @_LapeImage_DrawCircle);
addGlobalFunc('procedure TImage.DrawCircleFilled(ACenter: TPoint; Radius: Integer; Color: TColor);', @_LapeImage_DrawCircleFilled);
addGlobalFunc('procedure TImage.DrawCircleInverted(ACenter: TPoint; Radius: Integer; Color: TColor);', @_LapeImage_DrawCircleInverted);
addGlobalFunc('procedure TImage.DrawCircle(Circle: TCircle; Color: TColor);', @_LapeImage_DrawCircle);
addGlobalFunc('procedure TImage.DrawCircleFilled(Circle: TCircle; Color: TColor);', @_LapeImage_DrawCircleFilled);
addGlobalFunc('procedure TImage.DrawCircleInverted(Circle: TCircle; Color: TColor);', @_LapeImage_DrawCircleInverted);

addGlobalFunc('procedure TImage.DrawBox(B: TBox; Color: TColor);', @_LapeImage_DrawBox);
addGlobalFunc('procedure TImage.DrawBoxFilled(B: TBox; Color: TColor);', @_LapeImage_DrawBoxFilled);
Expand All @@ -1341,7 +1341,7 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('procedure TImage.DrawQuadArray(Quads: TQuadArray; Filled: Boolean; Color: TColor = -1);', @_LapeImage_DrawQuadArray);
addGlobalFunc('procedure TImage.DrawBoxArray(Boxes: TBoxArray; Filled: Boolean; Color: TColor = -1);', @_LapeImage_DrawBoxArray);
addGlobalFunc('procedure TImage.DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean; Color: TColor = -1);', @_LapeImage_DrawPolygonArray);
addGlobalFunc('procedure TImage.DrawCircleArray(Points: TPointArray; Radius: Integer; Filled: Boolean; Color: TColor = -1);', @_LapeImage_DrawCircleArray);
addGlobalFunc('procedure TImage.DrawCircleArray(Circles: TCircleArray; Filled: Boolean; Color: TColor = -1);', @_LapeImage_DrawCircleArray);
addGlobalFunc('procedure TImage.DrawCrossArray(Points: TPointArray; Radius: Integer; Thickness: Integer; Color: TColor = -1);', @_LapeImage_DrawCrossArray);

addGlobalFunc('procedure TImage.DrawHSLCircle(ACenter: TPoint; Radius: Integer)', @_LapeImage_DrawHSLCircle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ implementation

uses
lptypes,
simba.image, simba.externalimage;
simba.image, simba.externalimage, simba.circle;

procedure _LapeExternalImage_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
Expand Down Expand Up @@ -303,7 +303,7 @@ procedure _LapeExternalImage_DrawPolygonInverted(const Params: PParamArray); LAP
*)
procedure _LapeExternalImage_DrawCircle(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaExternalImage(Params^[0])^.DrawCircle(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^);
PSimbaExternalImage(Params^[0])^.DrawCircle(PCircle(Params^[1])^, PColor(Params^[2])^);
end;

(*
Expand All @@ -313,7 +313,7 @@ procedure _LapeExternalImage_DrawCircle(const Params: PParamArray); LAPE_WRAPPER
*)
procedure _LapeExternalImage_DrawCircleFilled(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaExternalImage(Params^[0])^.DrawCircleFilled(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^);
PSimbaExternalImage(Params^[0])^.DrawCircleFilled(PCircle(Params^[1])^, PColor(Params^[2])^);
end;

(*
Expand All @@ -323,7 +323,7 @@ procedure _LapeExternalImage_DrawCircleFilled(const Params: PParamArray); LAPE_W
*)
procedure _LapeExternalImage_DrawCircleInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaExternalImage(Params^[0])^.DrawCircleInverted(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^);
PSimbaExternalImage(Params^[0])^.DrawCircleInverted(PCircle(Params^[1])^, PColor(Params^[2])^);
end;

(*
Expand Down Expand Up @@ -423,7 +423,7 @@ procedure _LapeExternalImage_DrawPolygonArray(const Params: PParamArray); LAPE_W
*)
procedure _LapeExternalImage_DrawCircleArray(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaExternalImage(Params^[0])^.DrawCircleArray(PPointArray(Params^[1])^, PInteger(Params^[2])^, PBoolean(Params^[3])^, PColor(Params^[4])^);
PSimbaExternalImage(Params^[0])^.DrawCircleArray(PCircleArray(Params^[1])^, PBoolean(Params^[2])^, PColor(Params^[3])^);
end;

(*
Expand Down Expand Up @@ -549,9 +549,9 @@ procedure ImportSimbaExternalImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('procedure TExternalImage.DrawPolygonFilled(Points: TPointArray; Color: TColor);', @_LapeExternalImage_DrawPolygonFilled);
addGlobalFunc('procedure TExternalImage.DrawPolygonInverted(Points: TPointArray; Color: TColor);', @_LapeExternalImage_DrawPolygonInverted);

addGlobalFunc('procedure TExternalImage.DrawCircle(ACenter: TPoint; Radius: Integer; Color: TColor);', @_LapeExternalImage_DrawCircle);
addGlobalFunc('procedure TExternalImage.DrawCircleFilled(ACenter: TPoint; Radius: Integer; Color: TColor);', @_LapeExternalImage_DrawCircleFilled);
addGlobalFunc('procedure TExternalImage.DrawCircleInverted(ACenter: TPoint; Radius: Integer; Color: TColor);', @_LapeExternalImage_DrawCircleInverted);
addGlobalFunc('procedure TExternalImage.DrawCircle(Circle: TCircle; Color: TColor);', @_LapeExternalImage_DrawCircle);
addGlobalFunc('procedure TExternalImage.DrawCircleFilled(Circle: TCircle; Radius: Integer; Color: TColor);', @_LapeExternalImage_DrawCircleFilled);
addGlobalFunc('procedure TExternalImage.DrawCircleInverted(Circle: TCircle; Radius: Integer; Color: TColor);', @_LapeExternalImage_DrawCircleInverted);

addGlobalFunc('procedure TExternalImage.DrawBox(B: TBox; Color: TColor);', @_LapeExternalImage_DrawBox);
addGlobalFunc('procedure TExternalImage.DrawBoxFilled(B: TBox; Color: TColor);', @_LapeExternalImage_DrawBoxFilled);
Expand All @@ -564,7 +564,7 @@ procedure ImportSimbaExternalImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('procedure TExternalImage.DrawQuadArray(Quads: TQuadArray; Filled: Boolean; Color: TColor = -1);', @_LapeExternalImage_DrawQuadArray);
addGlobalFunc('procedure TExternalImage.DrawBoxArray(Boxes: TBoxArray; Filled: Boolean; Color: TColor = -1);', @_LapeExternalImage_DrawBoxArray);
addGlobalFunc('procedure TExternalImage.DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean; Color: TColor = -1);', @_LapeExternalImage_DrawPolygonArray);
addGlobalFunc('procedure TExternalImage.DrawCircleArray(Points: TPointArray; Radius: Integer; Filled: Boolean; Color: TColor = -1);', @_LapeExternalImage_DrawCircleArray);
addGlobalFunc('procedure TExternalImage.DrawCircleArray(Circles: TCircleArray; Filled: Boolean; Color: TColor = -1);', @_LapeExternalImage_DrawCircleArray);
addGlobalFunc('procedure TExternalImage.DrawCrossArray(Points: TPointArray; Radius: Integer; Thickness: Integer; Color: TColor = -1);', @_LapeExternalImage_DrawCrossArray);

addGlobalFunc('procedure TExternalImage.Clear; overload', @_LapeExternalImage_Clear);
Expand Down
2 changes: 2 additions & 0 deletions Source/simba.circle.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ TCircle = record
Center: TPoint;
Radius: Integer;
end;
PCircleArray = ^TCircleArray;
TCircleArray = array of TCircle;

TCircleHelper = type helper for TCircle
public const
Expand Down
27 changes: 14 additions & 13 deletions Source/simba.externalimage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ interface

uses
Classes, SysUtils, Graphics,
simba.mufasatypes, simba.baseclass, simba.image, simba.simplelock;
simba.mufasatypes, simba.baseclass, simba.image, simba.simplelock,
simba.circle;

type
TSimbaExternalImageCallback = procedure(Image: Pointer); cdecl;
Expand Down Expand Up @@ -83,9 +84,9 @@ TSimbaExternalImage = class(TSimbaBaseClass)
procedure DrawPolygonFilled(Points: TPointArray; Color: TColor);
procedure DrawPolygonInverted(Points: TPointArray; Color: TColor);

procedure DrawCircle(ACenter: TPoint; Radius: Integer; Color: TColor);
procedure DrawCircleFilled(ACenter: TPoint; Radius: Integer; Color: TColor);
procedure DrawCircleInverted(ACenter: TPoint; Radius: Integer; Color: TColor);
procedure DrawCircle(Circle: TCircle; Color: TColor);
procedure DrawCircleFilled(Circle: TCircle; Color: TColor);
procedure DrawCircleInverted(Circle: TCircle; Color: TColor);

procedure DrawBox(B: TBox; Color: TColor);
procedure DrawBoxFilled(B: TBox; Color: TColor);
Expand All @@ -98,7 +99,7 @@ TSimbaExternalImage = class(TSimbaBaseClass)
procedure DrawQuadArray(Quads: TQuadArray; Filled: Boolean; Color: TColor = -1);
procedure DrawBoxArray(Boxes: TBoxArray; Filled: Boolean; Color: TColor = -1);
procedure DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean; Color: TColor = -1);
procedure DrawCircleArray(Points: TPointArray; Radius: Integer; Filled: Boolean; Color: TColor = -1);
procedure DrawCircleArray(Circles: TCircleArray; Filled: Boolean; Color: TColor = -1);
procedure DrawCrossArray(Points: TPointArray; Radius: Integer; Color: TColor = -1);
end;

Expand Down Expand Up @@ -477,31 +478,31 @@ procedure TSimbaExternalImage.DrawPolygonInverted(Points: TPointArray; Color: TC
end;
end;

procedure TSimbaExternalImage.DrawCircle(ACenter: TPoint; Radius: Integer; Color: TColor);
procedure TSimbaExternalImage.DrawCircle(Circle: TCircle; Color: TColor);
begin
Lock();
try
FImage.DrawCircle(ACenter, Radius, Color);
FImage.DrawCircle(Circle, Color);
finally
Unlock();
end;
end;

procedure TSimbaExternalImage.DrawCircleFilled(ACenter: TPoint; Radius: Integer; Color: TColor);
procedure TSimbaExternalImage.DrawCircleFilled(Circle: TCircle; Color: TColor);
begin
Lock();
try
FImage.DrawCircleFilled(ACenter, Radius, Color);
FImage.DrawCircleFilled(Circle, Color);
finally
Unlock();
end;
end;

procedure TSimbaExternalImage.DrawCircleInverted(ACenter: TPoint; Radius: Integer; Color: TColor);
procedure TSimbaExternalImage.DrawCircleInverted(Circle: TCircle; Color: TColor);
begin
Lock();
try
FImage.DrawCircleInverted(ACenter, Radius, Color);
FImage.DrawCircleInverted(Circle, Color);
finally
Unlock();
end;
Expand Down Expand Up @@ -597,11 +598,11 @@ procedure TSimbaExternalImage.DrawPolygonArray(Polygons: T2DPointArray; Filled:
end;
end;

procedure TSimbaExternalImage.DrawCircleArray(Points: TPointArray; Radius: Integer; Filled: Boolean; Color: TColor);
procedure TSimbaExternalImage.DrawCircleArray(Circles: TCircleArray; Filled: Boolean; Color: TColor);
begin
Lock();
try
FImage.DrawCircleArray(Points, Radius, Filled, Color);
FImage.DrawCircleArray(Circles, Filled, Color);
finally
Unlock();
end;
Expand Down
Loading

0 comments on commit 71a30c5

Please sign in to comment.