diff --git a/Source/script/imports/simbaclasses/simba.import_class_image.pas b/Source/script/imports/simbaclasses/simba.import_class_image.pas index 9823ac342..097c88569 100644 --- a/Source/script/imports/simbaclasses/simba.import_class_image.pas +++ b/Source/script/imports/simbaclasses/simba.import_class_image.pas @@ -192,19 +192,9 @@ procedure _LapeImage_LoadFromFileEx(const Params: PParamArray); LAPE_WRAPPER_CAL (* TImage.DrawATPA ~~~~~~~~~~~~~~~ -> procedure TImage.DrawATPA(ATPA: T2DPointArray); +> procedure TImage.DrawATPA(ATPA: T2DPointArray; Color: TColor = -1); *) procedure _LapeImage_DrawATPA(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV -begin - PSimbaImage(Params^[0])^.DrawATPA(P2DPointArray(Params^[1])^); -end; - -(* -TImage.DrawATPA -~~~~~~~~~~~~~~~ -> procedure TImage.DrawATPA(ATPA: T2DPointArray; Color: TColor); -*) -procedure _LapeImage_DrawATPAEx(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin PSimbaImage(Params^[0])^.DrawATPA(P2DPointArray(Params^[1])^, PColor(Params^[2])^); end; @@ -1323,8 +1313,7 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler); addGlobalFunc('procedure TImage.DrawText(Text: String; Box: TBox; Center: Boolean; Color: TColor); overload', @_LapeImage_DrawTextEx); addGlobalFunc('procedure TImage.DrawTextLines(Text: TStringArray; Position: TPoint; Color: TColor);', @_LapeImage_DrawTextLines); - addGlobalFunc('procedure TImage.DrawATPA(ATPA: T2DPointArray); overload', @_LapeImage_DrawATPA); - addGlobalFunc('procedure TImage.DrawATPA(ATPA: T2DPointArray; Color: TColor); overload', @_LapeImage_DrawATPAEx); + addGlobalFunc('procedure TImage.DrawATPA(ATPA: T2DPointArray; Color: TColor)', @_LapeImage_DrawATPA); addGlobalFunc('procedure TImage.DrawTPA(TPA: TPointArray; Color: TColor);', @_LapeImage_DrawTPA); addGlobalFunc('procedure TImage.DrawCrosshairs(ACenter: TPoint; Size: Integer; Thickness: Integer; Color: TColor);', @_LapeImage_DrawCrosshairs); diff --git a/Source/script/imports/simbaclasses/simba.import_externalimage.pas b/Source/script/imports/simbaclasses/simba.import_externalimage.pas new file mode 100644 index 000000000..d1f6df513 --- /dev/null +++ b/Source/script/imports/simbaclasses/simba.import_externalimage.pas @@ -0,0 +1,579 @@ +unit simba.import_externalimage; + +{$i simba.inc} + +interface + +uses + Classes, SysUtils, Graphics, + simba.mufasatypes, simba.script_compiler; + +procedure ImportSimbaExternalImage(Compiler: TSimbaScript_Compiler); + +implementation + +uses + lptypes, + simba.image, simba.externalimage; + +procedure _LapeExternalImage_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PPointer(Result)^ := TSimbaExternalImage.Create(); +end; + +procedure _LapeExternalImage_FreeOnTerminate(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.FreeOnTerminate := PBoolean(Params^[1])^; +end; + +procedure _LapeExternalImage_Width(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PInteger(Result)^ := PSimbaExternalImage(Params^[0])^.Width(); +end; + +procedure _LapeExternalImage_Height(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PInteger(Result)^ := PSimbaExternalImage(Params^[0])^.Height(); +end; + +(* +TExternalImage.GetFontName +~~~~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.GetFontName: String; +*) +procedure _LapeExternalImage_FontName_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PString(Result)^ := PSimbaExternalImage(Params^[0])^.FontName; +end; + +(* +TExternalImage.SetFontName +~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.SetFontName(Value: String); +*) +procedure _LapeExternalImage_FontName_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.FontName := PString(Params^[1])^; +end; + +(* +TExternalImage.GetFontSize +~~~~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.GetFontSize: Single; +*) +procedure _LapeExternalImage_FontSize_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PSingle(Result)^ := PSimbaExternalImage(Params^[0])^.FontSize; +end; + +(* +TExternalImage.SetFontSize +~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.SetFontSize(Value: Single); +*) +procedure _LapeExternalImage_FontSize_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.FontSize := PSingle(Params^[1])^; +end; + +(* +TExternalImage.GetFontAntialiasing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.GetFontAntialiasing: Boolean; +*) +procedure _LapeExternalImage_FontAntialiasing_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PBoolean(Result)^ := PSimbaExternalImage(Params^[0])^.FontAntialiasing; +end; + +(* +TExternalImage.SetFontAntialiasing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.SetFontAntialiasing(Value: Boolean); +*) +procedure _LapeExternalImage_FontAntialiasing_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.FontAntialiasing := PBoolean(Params^[1])^; +end; + +(* +TExternalImage.GetFontBold +~~~~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.GetFontBold: Boolean; +*) +procedure _LapeExternalImage_FontBold_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PBoolean(Result)^ := PSimbaExternalImage(Params^[0])^.FontBold; +end; + +(* +TExternalImage.SetFontBold +~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.SetFontBold(Value: Boolean); +*) +procedure _LapeExternalImage_FontBold_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.FontBold := PBoolean(Params^[1])^; +end; + +(* +TExternalImage.GetFontItalic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.GetFontItalic: Boolean; +*) +procedure _LapeExternalImage_FontItalic_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PBoolean(Result)^ := PSimbaExternalImage(Params^[0])^.FontItalic; +end; + +(* +TExternalImage.SetFontItalic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.SetFontItalic(Value: Boolean); +*) +procedure _LapeExternalImage_FontItalic_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.FontItalic := PBoolean(Params^[1])^; +end; + +(* +TExternalImage.TextWidth +~~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.TextWidth(Text: String): Integer; +*) +procedure _LapeExternalImage_TextWidth(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PInteger(Result)^ := PSimbaExternalImage(Params^[0])^.TextWidth(PString(Params^[1])^); +end; + +(* +TExternalImage.TextHeight +~~~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.TextHeight(Text: String): Integer; +*) +procedure _LapeExternalImage_TextHeight(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PInteger(Result)^ := PSimbaExternalImage(Params^[0])^.TextHeight(PString(Params^[1])^); +end; + +(* +TExternalImage.TextSize +~~~~~~~~~~~~~~~~~~~~~~~ +> function TExternalImage.TextSize(Text: String): TPoint; +*) +procedure _LapeExternalImage_TextSize(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PPoint(Result)^ := PSimbaExternalImage(Params^[0])^.TextSize(PString(Params^[1])^); +end; + +(* +TExternalImage.DrawText +~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawText(Text: String; Position: TPoint; Color: TColor); +*) +procedure _LapeExternalImage_DrawText(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawText(PString(Params^[1])^, PPoint(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.Draw +~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.Draw(Image: TImage; Position: TPoint); +*) +procedure _LapeExternalImage_Draw(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.Draw(PSimbaImage(Params^[1])^, PPoint(Params^[2])^); +end; + +(* +TExternalImage.DrawText +~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawText(Text: String; Box: TBox; Center: Boolean; Color: TColor); +*) +procedure _LapeExternalImage_DrawTextEx(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawText(PString(Params^[1])^, PBox(Params^[2])^, PBoolean(Params^[3])^, PColor(Params^[4])^); +end; + +(* +TExternalImage.DrawTextLines +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawTextLines(Text: TStringArray; Position: TPoint; Color: TColor); +*) +procedure _LapeExternalImage_DrawTextLines(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawTextLines(PStringArray(Params^[1])^, PPoint(Params^[2])^, PInteger(Params^[3])^); +end; + +(* +TExternalImage.DrawATPA +~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawATPA(ATPA: T2DPointArray; Color: TColor = -1); +*) +procedure _LapeExternalImage_DrawATPA(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawATPA(P2DPointArray(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawTPA +~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawTPA(TPA: TPointArray; Color: TColor); +*) +procedure _LapeExternalImage_DrawTPA(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawTPA(PPointArray(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawCross +~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawCross(ACenter: TPoint; Radius: Integer; Color: TColor); +*) +procedure _LapeExternalImage_DrawCross(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawCross(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawCrosshairs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawCrosshairs(ACenter: TPoint; Size: Integer; Color: TColor); +*) +procedure _LapeExternalImage_DrawCrosshairs(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawCrosshairs(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawLine +~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawLine(Start, Stop: TPoint; Color: TColor); +*) +procedure _LapeExternalImage_DrawLine(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawLine(PPoint(Params^[1])^, PPoint(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawLine +~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawLine(Start, Stop: TPoint; Color: TColor); +*) +procedure _LapeExternalImage_DrawLineEx(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawLine(PPoint(Params^[1])^, PPoint(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawPolygon +~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawPolygon(Points: TPointArray; Color: TColor); +*) +procedure _LapeExternalImage_DrawPolygon(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawPolygon(PPointArray(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawPolygonFilled +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawPolygonFilled(Points: TPointArray; Color: TColor); +*) +procedure _LapeExternalImage_DrawPolygonFilled(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawPolygonFilled(PPointArray(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawPolygonInverted +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawPolygonInverted(Points: TPointArray; Color: TColor); +*) +procedure _LapeExternalImage_DrawPolygonInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawPolygonInverted(PPointArray(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawCircle +~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawCircle(ACenter: TPoint; Radius: Integer; Color: TColor); +*) +procedure _LapeExternalImage_DrawCircle(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawCircle(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawCircleFilled +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawCircleFilled(ACenter: TPoint; Radius: Integer; Color: TColor); +*) +procedure _LapeExternalImage_DrawCircleFilled(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawCircleFilled(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawCircleInverted +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawCircleInverted(ACenter: TPoint; Radius: Integer; Color: TColor); +*) +procedure _LapeExternalImage_DrawCircleInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawCircleInverted(PPoint(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawBox +~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawBox(B: TBox; Color: TColor); +*) +procedure _LapeExternalImage_DrawBox(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawBox(PBox(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawBoxFilled +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawBoxFilled(B: TBox; Color: TColor); +*) +procedure _LapeExternalImage_DrawBoxFilled(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawBoxFilled(PBox(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawBoxInverted +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawBoxInverted(B: TBox; Color: TColor); +*) +procedure _LapeExternalImage_DrawBoxInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawBoxInverted(PBox(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawQuad +~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawQuad(B: TBox; Color: TColor); +*) +procedure _LapeExternalImage_DrawQuad(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawQuad(PQuad(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawQuadFilled +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawQuadFilled(B: TBox; Color: TColor); +*) +procedure _LapeExternalImage_DrawQuadFilled(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawQuadFilled(PQuad(Params^[1])^, PColor(Params^[2])^); +end; + +(* +TExternalImage.DrawQuadInverted +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawQuadInverted(B: TBox; Color: TColor); +*) +procedure _LapeExternalImage_DrawQuadInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawQuadInverted(PQuad(Params^[1])^, PInteger(Params^[2])^); +end; + +(* +TExternalImage.DrawQuadArray +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawQuadArray(Quads: TQuadArray; Filled: Boolean; Color: TColor = -1); +*) +procedure _LapeExternalImage_DrawQuadArray(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawQuadArray(PQuadArray(Params^[1])^, PBoolean(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawBoxArray +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawBoxArray(Boxes: TBoxArray; Filled: Boolean; Color: TColor = -1); +*) +procedure _LapeExternalImage_DrawBoxArray(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawBoxArray(PBoxArray(Params^[1])^, PBoolean(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawPolygonArray +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean; Color: TColor = -1); +*) +procedure _LapeExternalImage_DrawPolygonArray(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawPolygonArray(P2DPointArray(Params^[1])^, PBoolean(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.DrawCircleArray +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawCircleArray(Points: TPointArray; Radius: Integer; Filled: Boolean; Color: TColor = -1); +*) +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])^); +end; + +(* +TExternalImage.DrawCrossArray +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.DrawCrossArray(Points: TPointArray; Radius: Integer; Color: TColor = -1); +*) +procedure _LapeExternalImage_DrawCrossArray(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.DrawCrossArray(PPointArray(Params^[1])^, PInteger(Params^[2])^, PColor(Params^[3])^); +end; + +(* +TExternalImage.Fill +~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.Fill(Color: TColor); +*) +procedure _LapeExternalImage_Fill(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.Fill(PColor(Params^[1])^); +end; + +(* +TExternalImage.Clear +~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.Clear; +*) +procedure _LapeExternalImage_Clear(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.Clear(); +end; + +(* +TExternalImage.Clear +~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.Clear(Area: TBox); +*) +procedure _LapeExternalImage_ClearEx(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.Clear(PBox(Params^[1])^); +end; + +(* +TExternalImage.ClearInverted +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +> procedure TExternalImage.ClearInverted(Area: TBox); +*) +procedure _LapeExternalImage_ClearInverted(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.ClearInverted(PBox(Params^[1])^); +end; + +procedure _LapeExternalImage_InternalImage(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaImage(Result)^ := PSimbaExternalImage(Params^[0])^.InternalImage(); +end; + +procedure _LapeExternalImage_TryLock(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PBoolean(Result)^ := PSimbaExternalImage(Params^[0])^.TryLock(); +end; + +procedure _LapeExternalImage_Lock(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.Lock(); +end; + +procedure _LapeExternalImage_Unlock(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.Unlock(); +end; + +procedure _LapeExternalImage_SetMemory(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSimbaExternalImage(Params^[0])^.SetMemory(PPointer(Params^[1])^, PInteger(Params^[2])^, PInteger(Params^[3])^); +end; + +procedure ImportSimbaExternalImage(Compiler: TSimbaScript_Compiler); +begin + with Compiler do + begin + addClass('TExternalImage'); + + addGlobalFunc('function TExternalImage.Create: TExternalImage; static;', @_LapeExternalImage_Create); + addGlobalFunc('procedure TExternalImage.FreeOnTerminate(Value: Boolean);', @_LapeExternalImage_FreeOnTerminate); + + addClassVar('TExternalImage', 'FontName', 'String', @_LapeExternalImage_FontName_Read, @_LapeExternalImage_FontName_Write); + addClassVar('TExternalImage', 'FontSize', 'Single', @_LapeExternalImage_FontSize_Read, @_LapeExternalImage_FontSize_Write); + addClassVar('TExternalImage', 'FontAntialiasing', 'Boolean', @_LapeExternalImage_FontAntialiasing_Read, @_LapeExternalImage_FontAntialiasing_Write); + addClassVar('TExternalImage', 'FontBold', 'Boolean', @_LapeExternalImage_FontBold_Read, @_LapeExternalImage_FontBold_Write); + addClassVar('TExternalImage', 'FontItalic', 'Boolean', @_LapeExternalImage_FontItalic_Read, @_LapeExternalImage_FontItalic_Write); + + addGlobalFunc('function TExternalImage.TextWidth(Text: String): Integer;', @_LapeExternalImage_TextWidth); + addGlobalFunc('function TExternalImage.TextHeight(Text: String): Integer;', @_LapeExternalImage_TextHeight); + addGlobalFunc('function TExternalImage.TextSize(Text: String): TPoint;', @_LapeExternalImage_TextSize); + + addGlobalFunc('procedure TExternalImage.DrawText(Text: String; Position: TPoint; Color: TColor); overload', @_LapeExternalImage_DrawText); + addGlobalFunc('procedure TExternalImage.DrawText(Text: String; Box: TBox; Center: Boolean; Color: TColor); overload', @_LapeExternalImage_DrawTextEx); + addGlobalFunc('procedure TExternalImage.DrawTextLines(Text: TStringArray; Position: TPoint; Color: TColor);', @_LapeExternalImage_DrawTextLines); + + addGlobalFunc('function TExternalImage.Width: Integer;', @_LapeExternalImage_Width); + addGlobalFunc('function TExternalImage.Height: Integer;', @_LapeExternalImage_Height); + + addGlobalFunc('function TExternalImage.InternalImage: TImage;', @_LapeExternalImage_InternalImage); + + addGlobalFunc('function TExternalImage.TryLock: Boolean;', @_LapeExternalImage_TryLock); + addGlobalFunc('procedure TExternalImage.Lock;', @_LapeExternalImage_Lock); + addGlobalFunc('procedure TExternalImage.Unlock;', @_LapeExternalImage_Unlock); + addGlobalFunc('procedure TExternalImage.SetMemory(Data: PColorBGRA; AWidth, AHeight: Integer);', @_LapeExternalImage_SetMemory); + + addGlobalFunc('procedure TExternalImage.Draw(Image: TImage; Position: TPoint);', @_LapeExternalImage_Draw); + + addGlobalFunc('procedure TExternalImage.DrawATPA(ATPA: T2DPointArray; Color: TColor)', @_LapeExternalImage_DrawATPA); + addGlobalFunc('procedure TExternalImage.DrawTPA(TPA: TPointArray; Color: TColor);', @_LapeExternalImage_DrawTPA); + + addGlobalFunc('procedure TExternalImage.DrawCrosshairs(ACenter: TPoint; Size: Integer; Thickness: Integer; Color: TColor);', @_LapeExternalImage_DrawCrosshairs); + addGlobalFunc('procedure TExternalImage.DrawCross(ACenter: TPoint; Radius: Integer; Thickness: Integer; Color: TColor);', @_LapeExternalImage_DrawCross); + + addGlobalFunc('procedure TExternalImage.DrawLine(Start, Stop: TPoint; Color: TColor); overload', @_LapeExternalImage_DrawLine); + addGlobalFunc('procedure TExternalImage.DrawLine(Start, Stop: TPoint; Thickness: Integer; Color: TColor); overload', @_LapeExternalImage_DrawLineEx); + + addGlobalFunc('procedure TExternalImage.DrawPolygon(Points: TPointArray; Color: TColor);', @_LapeExternalImage_DrawPolygon); + 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.DrawBox(B: TBox; Color: TColor);', @_LapeExternalImage_DrawBox); + addGlobalFunc('procedure TExternalImage.DrawBoxFilled(B: TBox; Color: TColor);', @_LapeExternalImage_DrawBoxFilled); + addGlobalFunc('procedure TExternalImage.DrawBoxInverted(B: TBox; Color: TColor);', @_LapeExternalImage_DrawBoxInverted); + + addGlobalFunc('procedure TExternalImage.DrawQuad(Quad: TQuad; Color: TColor);', @_LapeExternalImage_DrawQuad); + addGlobalFunc('procedure TExternalImage.DrawQuadFilled(Quad: TQuad; Color: TColor);', @_LapeExternalImage_DrawQuadFilled); + addGlobalFunc('procedure TExternalImage.DrawQuadInverted(Quad: TQuad; Color: TColor);', @_LapeExternalImage_DrawQuadInverted); + + 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.DrawCrossArray(Points: TPointArray; Radius: Integer; Thickness: Integer; Color: TColor = -1);', @_LapeExternalImage_DrawCrossArray); + + addGlobalFunc('procedure TExternalImage.Clear; overload', @_LapeExternalImage_Clear); + addGlobalFunc('procedure TExternalImage.Clear(Area: TBox); overload', @_LapeExternalImage_ClearEx); + addGlobalFunc('procedure TExternalImage.ClearInverted(Area: TBox);', @_LapeExternalImage_ClearInverted); + + addGlobalFunc('procedure TExternalImage.Fill(Color: TColor);', @_LapeExternalImage_Fill); + end; +end; + +end. + diff --git a/Source/script/simba.script_imports.pas b/Source/script/simba.script_imports.pas index e35503090..3abf2b842 100644 --- a/Source/script/simba.script_imports.pas +++ b/Source/script/simba.script_imports.pas @@ -28,7 +28,7 @@ implementation simba.import_lcl_comctrls, simba.import_lcl_misc, // Simba classes - simba.import_class_image, simba.import_class_dtm, simba.import_matchtemplate, + simba.import_class_image, simba.import_externalimage, simba.import_class_dtm, simba.import_matchtemplate, simba.import_class_json, simba.import_class_imagebox, simba.import_class_shapebox, // Simba @@ -61,6 +61,7 @@ procedure AddSimbaImports(Compiler: TSimbaScript_Compiler); ImportLCLMisc(Compiler); ImportSimbaImage(Compiler); + ImportSimbaExternalImage(Compiler); ImportDTM(Compiler); ImportMatchTemplate(Compiler); ImportJSON(Compiler); diff --git a/Source/script/simba.script_pluginmethods.pas b/Source/script/simba.script_pluginmethods.pas index f561fe1f5..26aa565d7 100644 --- a/Source/script/simba.script_pluginmethods.pas +++ b/Source/script/simba.script_pluginmethods.pas @@ -13,6 +13,7 @@ interface uses Classes, SysUtils, + simba.mufasatypes, simba.externalimage, lpcompiler; type @@ -44,6 +45,12 @@ interface SetArrayLength: procedure(TypeInfo: Pointer; var AVar: Pointer; NewLen: NativeInt); cdecl; GetArrayLength: function(AVar: Pointer): NativeInt; cdecl; + ExternalImage_Create: function(FreeOnTerminate: Boolean): Pointer; cdecl; + ExternalImage_SetMemory: procedure(Img: Pointer; Data: PColorBGRA; AWidth, AHeight: Integer); cdecl; + ExternalImage_TryLock: function(Img: Pointer): Boolean; cdecl; + ExternalImage_Lock: procedure(Img: Pointer); cdecl; + ExternalImage_UnLock: procedure(Img: Pointer); cdecl; + // Extend this but do not remove, reorder or change datatypes. end; @@ -53,7 +60,6 @@ interface implementation uses - simba.mufasatypes, lpvartypes, lpvartypes_record, lpvartypes_array, lpffiwrappers; // Sync wrapper which includes a data parameter @@ -261,6 +267,33 @@ function Plugin_GetArrayLength(Arr: Pointer): NativeInt; cdecl; Result := DynArraySize(Arr); end; +function Plugin_ExternalImage_Create(FreeOnTerminate: Boolean): Pointer; cdecl; +begin + Result := TSimbaExternalImage.Create(); + if FreeOnTerminate then + TSimbaExternalImage(Result).FreeOnTerminate := True; +end; + +procedure Plugin_ExternalImage_SetMemory(Img: Pointer; Data: PColorBGRA; AWidth, AHeight: Integer); cdecl; +begin + TSimbaExternalImage(Img).SetMemory(Data, AWidth, AHeight); +end; + +function Plugin_ExternalImage_TryLock(Img: Pointer): Boolean; cdecl; +begin + Result := TSimbaExternalImage(Img).TryLock(); +end; + +procedure Plugin_ExternalImage_Lock(Img: Pointer); cdecl; +begin + TSimbaExternalImage(Img).Lock(); +end; + +procedure Plugin_ExternalImage_UnLock(Img: Pointer); cdecl; +begin + TSimbaExternalImage(Img).UnLock(); +end; + initialization with SimbaPluginMethods do @@ -287,6 +320,12 @@ initialization SetArrayLength := @Plugin_SetArrayLength; GetArrayLength := @Plugin_GetArrayLength; + + ExternalImage_Create := @Plugin_ExternalImage_Create; + ExternalImage_SetMemory := @Plugin_ExternalImage_SetMemory; + ExternalImage_TryLock := @Plugin_ExternalImage_TryLock; + ExternalImage_Lock := @Plugin_ExternalImage_Lock; + ExternalImage_Unlock := @Plugin_ExternalImage_UnLock; end; end. diff --git a/Source/simba.externalimage.pas b/Source/simba.externalimage.pas new file mode 100644 index 000000000..81657fb1f --- /dev/null +++ b/Source/simba.externalimage.pas @@ -0,0 +1,586 @@ +unit simba.externalimage; + +{$i simba.inc} + +interface + +uses + Classes, SysUtils, Graphics, + simba.mufasatypes, simba.baseclass, simba.image, simba.simplelock; + +type + PSimbaExternalImage = ^TSimbaExternalImage; + TSimbaExternalImage = class(TSimbaBaseClass) + protected + FImage: TSimbaImage; + FLock: TSimpleEnterableLock; + + function GetFontAntialiasing: Boolean; + function GetFontBold: Boolean; + function GetFontItalic: Boolean; + function GetFontName: String; + function GetFontSize: Single; + + procedure SetFontAntialiasing(Value: Boolean); + procedure SetFontBold(Value: Boolean); + procedure SetFontItalic(Value: Boolean); + procedure SetFontName(Value: String); + procedure SetFontSize(Value: Single); + public + constructor Create; + destructor Destroy; override; + + function InternalImage: TSimbaImage; + + function TryLock: Boolean; + procedure Lock; inline; + procedure Unlock; inline; + + function Width: Integer; inline; + function Height: Integer; inline; + + property FontName: String read GetFontName write SetFontName; + property FontSize: Single read GetFontSize write SetFontSize; + property FontAntialiasing: Boolean read GetFontAntialiasing write SetFontAntialiasing; + property FontBold: Boolean read GetFontBold write SetFontBold; + property FontItalic: Boolean read GetFontItalic write SetFontItalic; + + procedure SetMemory(Data: PColorBGRA; AWidth, AHeight: Integer); + + function TextWidth(Text: String): Integer; + function TextHeight(Text: String): Integer; + function TextSize(Text: String): TPoint; + + procedure DrawText(Text: String; Position: TPoint; Color: TColor); overload; + procedure DrawText(Text: String; Box: TBox; ACenter: Boolean; Color: TColor); overload; + procedure DrawTextLines(Text: TStringArray; Position: TPoint; Color: TColor); + + procedure Fill(Color: TColor); + + procedure Clear; + procedure Clear(Area: TBox); + procedure ClearInverted(Area: TBox); + + procedure Draw(Image: TSimbaImage; Position: TPoint); + + procedure DrawATPA(ATPA: T2DPointArray; Color: TColor = -1); + procedure DrawTPA(Points: TPointArray; Color: TColor); + + procedure DrawCrosshairs(ACenter: TPoint; Size: Integer; Color: TColor); + procedure DrawCross(ACenter: TPoint; Radius: Integer; Color: TColor); + + procedure DrawLine(Start, Stop: TPoint; Color: TColor); + + procedure DrawPolygon(Points: TPointArray; Color: TColor); + 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 DrawBox(B: TBox; Color: TColor); + procedure DrawBoxFilled(B: TBox; Color: TColor); + procedure DrawBoxInverted(B: TBox; Color: TColor); + + procedure DrawQuad(Quad: TQuad; Color: TColor); + procedure DrawQuadFilled(Quad: TQuad; Color: TColor); + procedure DrawQuadInverted(Quad: TQuad; Color: TColor); + + 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 DrawCrossArray(Points: TPointArray; Radius: Integer; Color: TColor = -1); + end; + +implementation + +function TSimbaExternalImage.GetFontAntialiasing: Boolean; +begin + Lock(); + try + Result := FImage.FontAntialiasing; + finally + Unlock(); + end; +end; + +function TSimbaExternalImage.GetFontBold: Boolean; +begin + Lock(); + try + Result := FImage.FontBold; + finally + Unlock(); + end; +end; + +function TSimbaExternalImage.GetFontItalic: Boolean; +begin + Lock(); + try + Result := FImage.FontItalic; + finally + Unlock(); + end; +end; + +function TSimbaExternalImage.GetFontName: String; +begin + Lock(); + try + Result := FImage.FontName; + finally + Unlock(); + end; +end; + +function TSimbaExternalImage.GetFontSize: Single; +begin + Lock(); + try + Result := FImage.FontSize; + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.SetFontAntialiasing(Value: Boolean); +begin + Lock(); + try + FImage.FontAntialiasing := Value; + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.SetFontBold(Value: Boolean); +begin + Lock(); + try + FImage.FontBold := Value; + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.SetFontItalic(Value: Boolean); +begin + Lock(); + try + FImage.FontItalic := Value; + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.SetFontName(Value: String); +begin + Lock(); + try + FImage.FontName := Value; + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.SetFontSize(Value: Single); +begin + Lock(); + try + FImage.FontSize := Value; + finally + Unlock(); + end; +end; + +constructor TSimbaExternalImage.Create; +begin + inherited Create(); + + FImage := TSimbaImage.Create(); +end; + +destructor TSimbaExternalImage.Destroy; +begin + if Assigned(FImage) then + FreeAndNil(FImage); + + inherited Destroy(); +end; + +function TSimbaExternalImage.TryLock: Boolean; +begin + Result := FLock.TryEnter(); +end; + +procedure TSimbaExternalImage.Lock; +begin + FLock.Enter(); +end; + +procedure TSimbaExternalImage.Unlock; +begin + FLock.Leave(); +end; + +function TSimbaExternalImage.InternalImage: TSimbaImage; +begin + Result := FImage; +end; + +function TSimbaExternalImage.Width: Integer; +begin + Result := FImage.Width; +end; + +function TSimbaExternalImage.Height: Integer; +begin + Result := FImage.Height; +end; + +procedure TSimbaExternalImage.SetMemory(Data: PColorBGRA; AWidth, AHeight: Integer); +begin + Lock(); + try + FImage.ResetExternalData(); + FImage.SetExternalData(Data, AWidth, AHeight); + finally + Unlock(); + end; +end; + +function TSimbaExternalImage.TextWidth(Text: String): Integer; +begin + Lock(); + try + Result := FImage.TextWidth(Text); + finally + Unlock(); + end; +end; + +function TSimbaExternalImage.TextHeight(Text: String): Integer; +begin + Lock(); + try + Result := FImage.TextHeight(Text); + finally + Unlock(); + end; +end; + +function TSimbaExternalImage.TextSize(Text: String): TPoint; +begin + Lock(); + try + Result := FImage.TextSize(Text); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawText(Text: String; Position: TPoint; Color: TColor); +begin + Lock(); + try + FImage.DrawText(Text, Position, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawText(Text: String; Box: TBox; ACenter: Boolean; Color: TColor); +begin + Lock(); + try + FImage.DrawText(Text, Box, ACenter, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawTextLines(Text: TStringArray; Position: TPoint; Color: TColor); +begin + Lock(); + try + FImage.DrawTextLines(Text, Position, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.Fill(Color: TColor); +begin + Lock(); + try + FImage.Fill(Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.Clear; +begin + Lock(); + try + FImage.Clear(); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.Clear(Area: TBox); +begin + Lock(); + try + FImage.Clear(Area); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.ClearInverted(Area: TBox); +begin + Lock(); + try + FImage.ClearInverted(Area); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.Draw(Image: TSimbaImage; Position: TPoint); +begin + Lock(); + try + FImage.Draw(Image, Position); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawATPA(ATPA: T2DPointArray; Color: TColor); +begin + Lock(); + try + FImage.DrawATPA(ATPA, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawTPA(Points: TPointArray; Color: TColor); +begin + Lock(); + try + FImage.DrawTPA(Points, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawCrosshairs(ACenter: TPoint; Size: Integer; Color: TColor); +begin + Lock(); + try + FImage.DrawCrosshairs(ACenter, Size, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawCross(ACenter: TPoint; Radius: Integer; Color: TColor); +begin + Lock(); + try + FImage.DrawCross(ACenter, Radius, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawLine(Start, Stop: TPoint; Color: TColor); +begin + Lock(); + try + FImage.DrawLine(Start, Stop, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawPolygon(Points: TPointArray; Color: TColor); +begin + Lock(); + try + FImage.DrawPolygon(Points, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawPolygonFilled(Points: TPointArray; Color: TColor); +begin + Lock(); + try + FImage.DrawPolygonFilled(Points, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawPolygonInverted(Points: TPointArray; Color: TColor); +begin + Lock(); + try + FImage.DrawPolygonInverted(Points, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawCircle(ACenter: TPoint; Radius: Integer; Color: TColor); +begin + Lock(); + try + FImage.DrawCircle(ACenter, Radius, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawCircleFilled(ACenter: TPoint; Radius: Integer; Color: TColor); +begin + Lock(); + try + FImage.DrawCircleFilled(ACenter, Radius, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawCircleInverted(ACenter: TPoint; Radius: Integer; Color: TColor); +begin + Lock(); + try + FImage.DrawCircleInverted(ACenter, Radius, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawBox(B: TBox; Color: TColor); +begin + Lock(); + try + FImage.DrawBox(B, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawBoxFilled(B: TBox; Color: TColor); +begin + Lock(); + try + FImage.DrawBoxFilled(B, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawBoxInverted(B: TBox; Color: TColor); +begin + Lock(); + try + FImage.DrawBoxInverted(B, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawQuad(Quad: TQuad; Color: TColor); +begin + Lock(); + try + FImage.DrawQuad(Quad, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawQuadFilled(Quad: TQuad; Color: TColor); +begin + Lock(); + try + FImage.DrawQuadFilled(Quad, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawQuadInverted(Quad: TQuad; Color: TColor); +begin + Lock(); + try + FImage.DrawQuadInverted(Quad, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawQuadArray(Quads: TQuadArray; Filled: Boolean; Color: TColor); +begin + Lock(); + try + FImage.DrawQuadArray(Quads, Filled, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawBoxArray(Boxes: TBoxArray; Filled: Boolean; Color: TColor); +begin + Lock(); + try + FImage.DrawBoxArray(Boxes, Filled, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawPolygonArray(Polygons: T2DPointArray; Filled: Boolean; Color: TColor); +begin + Lock(); + try + FImage.DrawPolygonArray(Polygons, Filled, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawCircleArray(Points: TPointArray; Radius: Integer; Filled: Boolean; Color: TColor); +begin + Lock(); + try + FImage.DrawCircleArray(Points, Radius, Filled, Color); + finally + Unlock(); + end; +end; + +procedure TSimbaExternalImage.DrawCrossArray(Points: TPointArray; Radius: Integer; Color: TColor); +begin + Lock(); + try + FImage.DrawCrossArray(Points, Radius, Color); + finally + Unlock(); + end; +end; + +end. + diff --git a/Source/simba.image.pas b/Source/simba.image.pas index 094fa5ad9..518b0f5ed 100644 --- a/Source/simba.image.pas +++ b/Source/simba.image.pas @@ -117,8 +117,7 @@ TSimbaImage = class(TSimbaBaseClass) procedure SetExternalData(AData: PColorBGRA; AWidth, AHeight: Integer); procedure ResetExternalData; - procedure DrawATPA(ATPA: T2DPointArray); overload; - procedure DrawATPA(ATPA: T2DPointArray; Color: TColor); overload; + procedure DrawATPA(ATPA: T2DPointArray; Color: TColor = -1); procedure DrawTPA(Points: TPointArray; Color: TColor); procedure DrawCrosshairs(ACenter: TPoint; Size: Integer; Color: TColor); @@ -804,20 +803,12 @@ procedure TSimbaImage.LoadFromImage(Image: TSimbaImage); Move(Image.FData^, FData^, FWidth * FHeight * SizeOf(TColorBGRA)); end; -procedure TSimbaImage.DrawATPA(ATPA: T2DPointArray); -var - I: Integer; -begin - for I := 0 to High(ATPA) do - DrawTPA(ATPA[I], GetDistinctColor(-1, I)); -end; - procedure TSimbaImage.DrawATPA(ATPA: T2DPointArray; Color: TColor); var I: Integer; begin for I := 0 to High(ATPA) do - DrawTPA(ATPA[I], Color); + DrawTPA(ATPA[I], GetDistinctColor(Color, I)); end; procedure TSimbaImage.DrawTPA(Points: TPointArray; Color: TColor); diff --git a/Source/simba.simplelock.pas b/Source/simba.simplelock.pas index 0c11648d6..1db5d1996 100644 --- a/Source/simba.simplelock.pas +++ b/Source/simba.simplelock.pas @@ -47,8 +47,9 @@ TSimpleEnterableLock = record private FLock: TCriticalSection; public - procedure Enter; - procedure Leave; + function TryEnter: Boolean; inline; + procedure Enter; inline; + procedure Leave; inline; class operator Initialize(var Self: TSimpleEnterableLock); class operator Finalize(var Self: TSimpleEnterableLock); @@ -84,6 +85,11 @@ class function TSimpleThreadsafeLimit.Create(Limit: Integer): TSimpleThreadsafeL Result.FLimit := Limit; end; +function TSimpleEnterableLock.TryEnter: Boolean; +begin + Result := FLock.TryEnter(); +end; + procedure TSimpleEnterableLock.Enter; begin FLock.Enter();