Skip to content

Commit

Permalink
ver.3.2.0
Browse files Browse the repository at this point in the history
- Aligned to latest Image32 Library
- Updated Copyright
- Added Clipboard copy SVG as PNG (issue #12)
- Built with Delphi 12
  • Loading branch information
carloBarazzetta committed Jan 8, 2024
1 parent 7d11de0 commit c2fe3aa
Show file tree
Hide file tree
Showing 75 changed files with 1,440 additions and 922 deletions.
44 changes: 22 additions & 22 deletions Ext/SVGIconImageList/Image32/source/Clipper.Core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(*******************************************************************************
* Author : Angus Johnson *
* Date : 19 February 2023 *
* Date : 17 July 2023 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Purpose : Core Clipper Library module *
Expand Down Expand Up @@ -120,6 +120,7 @@ TListEx = class
protected
function UnsafeGet(idx: integer): Pointer; // no range checking
procedure UnsafeSet(idx: integer; val: Pointer);
procedure UnsafeDelete(index: integer); virtual;
public
constructor Create(capacity: integer = 0); virtual;
destructor Destroy; override;
Expand Down Expand Up @@ -347,6 +348,9 @@ procedure CheckPrecisionRange(var precision: integer);
NullRectD : TRectD = (left: 0; top: 0; right: 0; Bottom: 0);
Tolerance : Double = 1.0E-12;

//https://github.com/AngusJohnson/Clipper2/discussions/564
MaxDecimalPrecision = 8;

implementation

resourcestring
Expand Down Expand Up @@ -608,6 +612,14 @@ procedure TListEx.UnsafeSet(idx: integer; val: Pointer);
end;
//------------------------------------------------------------------------------

procedure TListEx.UnsafeDelete(index: integer);
begin
dec(fCount);
if index < fCount then
Move(fList[index +1], fList[index], (fCount - index) * SizeOf(Pointer));
end;
//------------------------------------------------------------------------------

procedure TListEx.Swap(idx1, idx2: integer);
var
p: Pointer;
Expand All @@ -623,7 +635,7 @@ procedure TListEx.Swap(idx1, idx2: integer);

procedure CheckPrecisionRange(var precision: integer);
begin
if (precision < -8) or (precision > 8) then
if (precision < -MaxDecimalPrecision) or (precision > MaxDecimalPrecision) then
Raise EClipper2LibException(rsClipper_PrecisonErr);
end;
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -1922,36 +1934,24 @@ function __Trunc(val: double): Int64; {$IFDEF INLINE} inline; {$ENDIF}
end;
//------------------------------------------------------------------------------

function CheckCastInt64(val: double): Int64; {$IFDEF INLINE} inline; {$ENDIF}
begin
if (val >= MaxCoord) or (val <= MinCoord) then
Raise EClipper2LibException.Create('overflow error.');
Result := Trunc(val);
//Result := __Trunc(val);
end;
//------------------------------------------------------------------------------

function GetIntersectPoint(const ln1a, ln1b, ln2a, ln2b: TPoint64;
out ip: TPoint64): Boolean;
var
dx1,dy1, dx2,dy2, qx,qy, cp: double;
dx1,dy1, dx2,dy2, t, cp: double;
begin
// https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
dy1 := (ln1b.y - ln1a.y);
dx1 := (ln1b.x - ln1a.x);
dy2 := (ln2b.y - ln2a.y);
dx2 := (ln2b.x - ln2a.x);
cp := dy1 * dx2 - dy2 * dx1;
if (cp = 0.0) then
begin
Result := false;
Exit;
end;
qx := dx1 * ln1a.y - dy1 * ln1a.x;
qy := dx2 * ln2a.y - dy2 * ln2a.x;
ip.X := CheckCastInt64((dx1 * qy - dx2 * qx) / cp);
ip.Y := CheckCastInt64((dy1 * qy - dy2 * qx) / cp);
Result := (ip.x <> invalid64) and (ip.y <> invalid64);
Result := (cp <> 0.0);
if not Result then Exit;
t := ((ln1a.x-ln2a.x) * dy2 - (ln1a.y-ln2a.y) * dx2) / cp;
if t <= 0.0 then ip := ln1a
else if t >= 1.0 then ip := ln1b;
ip.X := Trunc(ln1a.X + t * dx1);
ip.Y := Trunc(ln1a.Y + t * dy1);
end;
//------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit c2fe3aa

Please sign in to comment.