From b53b214b209695e8742d525e22deca9e6e755470 Mon Sep 17 00:00:00 2001 From: ronaldhordijk Date: Wed, 23 Mar 2005 13:28:13 +0000 Subject: [PATCH] Cause of sometimes 'invalid floating point' message --- 2.02g/Source/Adjust.dfm | 4 +++- 2.02g/Source/Adjust.pas | 9 ++++++-- 2.02g/Source/ControlPoint.pas | 42 +++++++++++++++++++++++------------ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/2.02g/Source/Adjust.dfm b/2.02g/Source/Adjust.dfm index fe64e63..116f4fe 100644 --- a/2.02g/Source/Adjust.dfm +++ b/2.02g/Source/Adjust.dfm @@ -57,6 +57,9 @@ object AdjustForm: TAdjustForm BevelOuter = bvLowered Color = clAppWorkSpace TabOrder = 0 + DesignSize = ( + 162 + 122) object PreviewImage: TImage Left = 1 Top = 1 @@ -312,7 +315,6 @@ object AdjustForm: TAdjustForm end end object ColorDialog: TColorDialog - Ctl3D = True Options = [cdFullOpen] Left = 376 Top = 8 diff --git a/2.02g/Source/Adjust.pas b/2.02g/Source/Adjust.pas index 497d997..283017f 100644 --- a/2.02g/Source/Adjust.pas +++ b/2.02g/Source/Adjust.pas @@ -157,8 +157,13 @@ begin scrollBrightness.Position := trunc(cp.Brightness * 100); scrollVibrancy.Position := trunc(cp.vibrancy * 100); scrollZoom.Position := trunc(cp.zoom * 100); - scrollCenterX.Position := trunc(cp.Center[0] * 100); - scrollCenterY.Position := trunc(cp.Center[1] * 100); + if (abs(cp.Center[0]) < 1000) and (abs(cp.Center[0]) < 1000) then begin + scrollCenterX.Position := trunc(cp.Center[0] * 100); + scrollCenterY.Position := trunc(cp.Center[1] * 100); + end else begin + scrollCenterX.Position := 0; + scrollCenterY.Position := 0; + end; ColorPanel.color := cp.background[2] shl 16 + cp.background[1] shl 8 + cp.background[0]; Resetting := False; diff --git a/2.02g/Source/ControlPoint.pas b/2.02g/Source/ControlPoint.pas index c75c6f3..c9603c2 100644 --- a/2.02g/Source/ControlPoint.pas +++ b/2.02g/Source/ControlPoint.pas @@ -878,18 +878,17 @@ begin xform[i].vars[j] := 0; end; - if rv < 0 then - begin + if rv < 0 then begin repeat v := Mixed_var_distrib[random(Length(mixed_var_distrib))]; until Variations[v]; // use only variations set in options xform[i].vars[v] := 1 - end - else + end else xform[i].vars[rv] := 1; end; - if calc then CalcBoundbox; + if calc then + CalcBoundbox; end; procedure TControlPoint.RandomCP1; @@ -927,10 +926,10 @@ begin LimitOutSidePoints := Round(0.05 * SUB_BATCH_SIZE); - minx := 1E10; - maxx := -1E10; - miny := 1E10; - maxy := -1E10; + minx := 1E99; + maxx := -1E99; + miny := 1E99; + maxy := -1E99; for i := 0 to SUB_BATCH_SIZE - 1 do begin minx := min(minx, Points[i].x); maxx := max(maxx, Points[i].x); @@ -986,6 +985,11 @@ begin deltay := deltay / 2; end; + + if ((maxx - minx) > 1000) or + ((maxy - miny) > 1000) then + raise Exception.Create('Flame area to large'); + center[0] := (minx + maxx) / 2; center[1] := (miny + maxy) / 2; if ((maxx - minx) > 0.001) and ((maxy - miny) > 0.001) then @@ -1018,10 +1022,10 @@ begin LimitOutSidePoints := Round(0.05 * SUB_BATCH_SIZE); - minx := 1E10; - maxx := -1E10; - miny := 1E10; - maxy := -1E10; + minx := 1E99; + maxx := -1E99; + miny := 1E99; + maxy := -1E99; for i := 0 to SUB_BATCH_SIZE - 1 do begin minx := min(minx, Points[i].x); maxx := max(maxx, Points[i].x); @@ -1077,6 +1081,11 @@ begin deltay := deltay / 2; end; + + if ((maxx - minx) > 1000) or + ((maxy - miny) > 1000) then + raise Exception.Create('Flame area to large'); + cp.center[0] := (minx + maxx) / 2; cp.center[1] := (miny + maxy) / 2; if ((maxx - minx) > 0.001) and ((maxy - miny) > 0.001) then @@ -1097,7 +1106,12 @@ begin end; except on E: EMathError do - raise Exception.Create('CalcUPRMagn: ' +e.Message); + begin// default + cp.center[0] := 0; + cp.center[1] := 0; + cp.pixels_per_unit := 10; + raise Exception.Create('CalcUPRMagn: ' +e.Message); + end; end; end;