Skip to content

Commit

Permalink
ver. 1.5.3
Browse files Browse the repository at this point in the history
- Added File Changed notification and reload
- Built with Delphi 12.1
- Built with Latest Image32 Library
- Built with Latest Skia4Delphi 6.1 Library
  • Loading branch information
carloBarazzetta committed May 9, 2024
1 parent 9d98fb9 commit 8a9b93a
Show file tree
Hide file tree
Showing 73 changed files with 11,869 additions and 4,308 deletions.
107 changes: 69 additions & 38 deletions Ext/SVGIconImageList/Image32/source/Clipper.Core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

(*******************************************************************************
* Author : Angus Johnson *
* Date : 17 July 2023 *
* Date : 14 February 2024 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : Core Clipper Library module *
* Contains structures and functions used throughout the library *
* License : http://www.boost.org/LICENSE_1_0.txt *
Expand Down Expand Up @@ -64,6 +64,7 @@ TPointD = record
function GetWidth: Int64; {$IFDEF INLINING} inline; {$ENDIF}
function GetHeight: Int64; {$IFDEF INLINING} inline; {$ENDIF}
function GetIsEmpty: Boolean; {$IFDEF INLINING} inline; {$ENDIF}
function GetIsValid: Boolean; {$IFDEF INLINING} inline; {$ENDIF}
function GetMidPoint: TPoint64; {$IFDEF INLINING} inline; {$ENDIF}
public
Left : Int64;
Expand All @@ -78,6 +79,7 @@ TPointD = record
property Width: Int64 read GetWidth;
property Height: Int64 read GetHeight;
property IsEmpty: Boolean read GetIsEmpty;
property IsValid: Boolean read GetIsValid;
property MidPoint: TPoint64 read GetMidPoint;
end;

Expand All @@ -86,6 +88,7 @@ TPointD = record
function GetWidth: double; {$IFDEF INLINING} inline; {$ENDIF}
function GetHeight: double; {$IFDEF INLINING} inline; {$ENDIF}
function GetIsEmpty: Boolean; {$IFDEF INLINING} inline; {$ENDIF}
function GetIsValid: Boolean; {$IFDEF INLINING} inline; {$ENDIF}
function GetMidPoint: TPointD; {$IFDEF INLINING} inline; {$ENDIF}
public
Left : double;
Expand All @@ -99,6 +102,7 @@ TPointD = record
property Width: double read GetWidth;
property Height: double read GetHeight;
property IsEmpty: Boolean read GetIsEmpty;
property IsValid: Boolean read GetIsValid;
property MidPoint: TPointD read GetMidPoint;
end;

Expand Down Expand Up @@ -168,8 +172,8 @@ function DistanceSqr(const pt1, pt2: TPoint64): double; overload;
{$IFDEF INLINING} inline; {$ENDIF}
function DistanceSqr(const pt1, pt2: TPointD): double; overload;
{$IFDEF INLINING} inline; {$ENDIF}
function DistanceFromLineSqrd(const pt, linePt1, linePt2: TPoint64): double; overload;
function DistanceFromLineSqrd(const pt, linePt1, linePt2: TPointD): double; overload;
function PerpendicDistFromLineSqrd(const pt, linePt1, linePt2: TPoint64): double; overload;
function PerpendicDistFromLineSqrd(const pt, linePt1, linePt2: TPointD): double; overload;

function SegmentsIntersect(const s1a, s1b, s2a, s2b: TPoint64;
inclusive: Boolean = false): boolean; {$IFDEF INLINING} inline; {$ENDIF}
Expand Down Expand Up @@ -311,7 +315,7 @@ procedure AppendPaths(var paths: TPathsD; const extra: TPathsD); overload;

function ArrayOfPathsToPaths(const ap: TArrayOfPaths): TPaths64;

function GetIntersectPoint(const ln1a, ln1b, ln2a, ln2b: TPoint64;
function GetSegmentIntersectPt(const ln1a, ln1b, ln2a, ln2b: TPoint64;
out ip: TPoint64): Boolean;

function PointInPolygon(const pt: TPoint64; const polygon: TPath64): TPointInPolygonResult;
Expand All @@ -333,8 +337,14 @@ procedure QuickSort(SortList: TPointerList;

procedure CheckPrecisionRange(var precision: integer);

function Iif(eval: Boolean; trueVal, falseVal: Boolean): Boolean; overload;
function Iif(eval: Boolean; trueVal, falseVal: integer): integer; overload;
function Iif(eval: Boolean; trueVal, falseVal: Int64): Int64; overload;
function Iif(eval: Boolean; trueVal, falseVal: double): double; overload;

const
MaxInt64 = 9223372036854775807;
MinInt64 = -MaxInt64;
MaxCoord = MaxInt64 div 4;
MinCoord = - MaxCoord;
invalid64 = MaxInt64;
Expand All @@ -346,6 +356,11 @@ procedure CheckPrecisionRange(var precision: integer);
InvalidPtD : TPointD = (X: invalidD; Y: invalidD);

NullRectD : TRectD = (left: 0; top: 0; right: 0; Bottom: 0);
InvalidRect64 : TRect64 =
(left: invalid64; top: invalid64; right: invalid64; bottom: invalid64);
InvalidRectD : TRectD =
(left: invalidD; top: invalidD; right: invalidD; bottom: invalidD);

Tolerance : Double = 1.0E-12;

//https://github.com/AngusJohnson/Clipper2/discussions/564
Expand Down Expand Up @@ -378,6 +393,12 @@ function TRect64.GetIsEmpty: Boolean;
end;
//------------------------------------------------------------------------------

function TRect64.GetIsValid: Boolean;
begin
result := left <> invalid64;
end;
//------------------------------------------------------------------------------

function TRect64.GetMidPoint: TPoint64;
begin
result := Point64((Left + Right) div 2, (Top + Bottom) div 2);
Expand Down Expand Up @@ -450,6 +471,12 @@ function TRectD.GetIsEmpty: Boolean;
end;
//------------------------------------------------------------------------------

function TRectD.GetIsValid: Boolean;
begin
result := left <> invalidD;
end;
//------------------------------------------------------------------------------

function TRectD.GetMidPoint: TPointD;
begin
result := PointD((Left + Right) *0.5, (Top + Bottom) *0.5);
Expand Down Expand Up @@ -633,6 +660,34 @@ procedure TListEx.Swap(idx1, idx2: integer);
// Miscellaneous Functions ...
//------------------------------------------------------------------------------

function Iif(eval: Boolean; trueVal, falseVal: Boolean): Boolean;
{$IFDEF INLINING} inline; {$ENDIF}
begin
if eval then Result := trueVal else Result := falseVal;
end;
//------------------------------------------------------------------------------

function Iif(eval: Boolean; trueVal, falseVal: integer): integer;
{$IFDEF INLINING} inline; {$ENDIF}
begin
if eval then Result := trueVal else Result := falseVal;
end;
//------------------------------------------------------------------------------

function Iif(eval: Boolean; trueVal, falseVal: Int64): Int64;
{$IFDEF INLINING} inline; {$ENDIF}
begin
if eval then Result := trueVal else Result := falseVal;
end;
//------------------------------------------------------------------------------

function Iif(eval: Boolean; trueVal, falseVal: double): double;
{$IFDEF INLINING} inline; {$ENDIF}
begin
if eval then Result := trueVal else Result := falseVal;
end;
//------------------------------------------------------------------------------

procedure CheckPrecisionRange(var precision: integer);
begin
if (precision < -MaxDecimalPrecision) or (precision > MaxDecimalPrecision) then
Expand Down Expand Up @@ -1831,7 +1886,7 @@ function DistanceSqr(const pt1, pt2: TPointD): double;
end;
//------------------------------------------------------------------------------

function DistanceFromLineSqrd(const pt, linePt1, linePt2: TPoint64): double;
function PerpendicDistFromLineSqrd(const pt, linePt1, linePt2: TPoint64): double;
var
a,b,c: double;
begin
Expand All @@ -1842,19 +1897,23 @@ function DistanceFromLineSqrd(const pt, linePt1, linePt2: TPoint64): double;
b := (linePt2.X - linePt1.X);
c := a * linePt1.X + b * linePt1.Y;
c := a * pt.x + b * pt.y - c;
Result := (c * c) / (a * a + b * b);
if (a = 0) and (b = 0) then
Result := 0 else
Result := (c * c) / (a * a + b * b);
end;
//---------------------------------------------------------------------------

function DistanceFromLineSqrd(const pt, linePt1, linePt2: TPointD): double;
function PerpendicDistFromLineSqrd(const pt, linePt1, linePt2: TPointD): double;
var
a,b,c: double;
begin
a := (linePt1.Y - linePt2.Y);
b := (linePt2.X - linePt1.X);
c := a * linePt1.X + b * linePt1.Y;
c := a * pt.x + b * pt.y - c;
Result := (c * c) / (a * a + b * b);
if (a = 0) and (b = 0) then
Result := 0 else
Result := (c * c) / (a * a + b * b);
end;
//---------------------------------------------------------------------------

Expand Down Expand Up @@ -1934,7 +1993,7 @@ function __Trunc(val: double): Int64; {$IFDEF INLINE} inline; {$ENDIF}
end;
//------------------------------------------------------------------------------

function GetIntersectPoint(const ln1a, ln1b, ln2a, ln2b: TPoint64;
function GetSegmentIntersectPt(const ln1a, ln1b, ln2a, ln2b: TPoint64;
out ip: TPoint64): Boolean;
var
dx1,dy1, dx2,dy2, t, cp: double;
Expand Down Expand Up @@ -2119,20 +2178,6 @@ function GetClosestPointOnSegment(const pt, seg1, seg2: TPoint64): TPoint64;
end;
//------------------------------------------------------------------------------

function PerpendicDistFromLineSqrd(const pt, line1, line2: TPoint64): double; overload;
var
a,b,c,d: double;
begin
a := pt.X - line1.X;
b := pt.Y - line1.Y;
c := line2.X - line1.X;
d := line2.Y - line1.Y;
if (c = 0) and (d = 0) then
result := 0 else
result := Sqr(a * d - c * b) / (c * c + d * d);
end;
//------------------------------------------------------------------------------

procedure RDP(const path: TPath64; startIdx, endIdx: integer;
epsilonSqrd: double; var boolArray: TArrayOfBoolean); overload;
var
Expand Down Expand Up @@ -2162,20 +2207,6 @@ procedure RDP(const path: TPath64; startIdx, endIdx: integer;
end;
//------------------------------------------------------------------------------

function PerpendicDistFromLineSqrd(const pt, line1, line2: TPointD): double; overload;
var
a,b,c,d: double;
begin
a := pt.X - line1.X;
b := pt.Y - line1.Y;
c := line2.X - line1.X;
d := line2.Y - line1.Y;
if (c = 0) and (d = 0) then
result := 0 else
result := Sqr(a * d - c * b) / (c * c + d * d);
end;
//------------------------------------------------------------------------------

procedure RDP(const path: TPathD; startIdx, endIdx: integer;
epsilonSqrd: double; var boolArray: TArrayOfBoolean); overload;
var
Expand Down
Loading

0 comments on commit 8a9b93a

Please sign in to comment.