"plot and retrace" mode added

This commit is contained in:
zueuk 2008-07-28 04:02:37 +00:00
parent c3b7b1ef28
commit 6ff3f4d1b5
8 changed files with 203 additions and 94 deletions

View File

@ -78,7 +78,7 @@ type
type
TPointsArray = array of TCPpoint;
TPointsXYArray = array of TXYpoint;
//TPointsXYArray = array of TXYpoint;
P2Cpoint = ^T2Cpoint;
T2CPointsArray = array of T2Cpoint;
@ -129,7 +129,7 @@ type
jitters: integer;
gamma_treshold: double;
// PropTable: array of TXForm;//Integer;
// PropTable: array of TXForm;
FAngle: Double;
FTwoColorDimensions: Boolean;
@ -155,10 +155,9 @@ type
// class function interpolate(cp1, cp2: TControlPoint; Time: double): TControlPoint; /// just for now
procedure InterpolateX(cp1, cp2: TControlPoint; Tm: double);
// procedure Iterate_Old(NrPoints: integer; var Points: TPointsArray);
procedure IterateXY(NrPoints: integer; var Points: TPointsXYArray);
// procedure IterateXY(NrPoints: integer; var Points: TPointsXYArray);
procedure IterateXYC(NrPoints: integer; var Points: TPointsArray);
procedure IterateXYCC(NrPoints: integer; var Points: T2CPointsArray);
// procedure IterateXYCC(NrPoints: integer; var Points: T2CPointsArray);
procedure Prepare;
// procedure Testiterate(NrPoints: integer; var Points: TPointsArray);
@ -352,6 +351,7 @@ begin
end;
end;
(*
procedure TControlPoint.IterateXY(NrPoints: integer; var Points: TPointsXYArray);
var
i: Integer;
@ -372,37 +372,38 @@ begin
pPoint := @Points[0];
if UseFinalXform then
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPointXY(px,py);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
pPoint^.X := px;
pPoint^.Y := py;
if UseFinalXform then
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPointXY(px,py);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
pPoint^.X := px;
pPoint^.Y := py;
end;
finalXform.NextPointXY(pPoint^.X, pPoint^.y);
Inc(pPoint);
end
else
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPointXY(px,py);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
pPoint.X := px;
pPoint.Y := py;
end;
Inc(pPoint);
end;
finalXform.NextPointXY(pPoint^.X, pPoint^.y);
Inc(pPoint);
end
else
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPointXY(px,py);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
pPoint.X := px;
pPoint.Y := py;
end;
Inc(pPoint);
end
except
on EMathError do begin
exit;
end;
end;
end;
*)
procedure TControlPoint.IterateXYC(NrPoints: integer; var Points: TPointsArray);
var
@ -436,34 +437,52 @@ end;
xf := xform[0];//random(NumXForms)];
for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
if xf.RetraceXform then continue;
xf.NextPoint(p);
end;
pPoint := @Points[0];
if UseFinalXform then
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else
finalXform.NextPointTo(p, pPoint^);
Inc(pPoint);
end
else
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
pPoint^.x := p.x;
pPoint^.y := p.y;
pPoint^.c := p.c;
if UseFinalXform then
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
if xf.RetraceXform then begin
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
xf.NextPointTo(p, pPoint^);
finalXform.NextPoint(pPoint^);
end;
end
else begin
xf.NextPoint(p);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else
finalXform.NextPointTo(p, pPoint^);
end;
Inc(pPoint);
end
else
for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
if xf.RetraceXform then begin
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else
xf.NextPointTo(p, pPoint^);
end
else begin
xf.NextPoint(p);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
//pPoint^.x := p.x; pPoint^.y := p.y; pPoint^.c := p.c;
pPoint^ := p;
end;
end;
Inc(pPoint);
end;
Inc(pPoint);
end
except
on EMathError do begin
exit;
@ -519,6 +538,7 @@ begin
end;
}
{
procedure TControlPoint.IterateXYCC(NrPoints: integer; var Points: T2CPointsArray);
var
i: Integer;
@ -568,14 +588,14 @@ else
end;
end;
end;
}
function TControlPoint.BlowsUp(NrPoints: integer): boolean;
var
i, n: Integer;
px, py: double;
minx, maxx, miny, maxy: double;
Points: TPointsXYArray;
Points: TPointsArray; //TPointsXYArray;
CurrentPoint: PXYPoint;
xf: TXForm;
@ -862,7 +882,10 @@ begin
end else if AnsiCompareText(CurrentToken, 'plotmode') = 0 then begin
Inc(ParsePos);
xform[CurrentXForm].noPlot := StrToInt(ParseValues[ParsePos]) <> 0;
xform[CurrentXForm].noPlot := (ParseValues[ParsePos] = '1');
end else if AnsiCompareText(CurrentToken, 'retrace') = 0 then begin
Inc(ParsePos);
xform[CurrentXForm].RetraceXform := (ParseValues[ParsePos] = '1');
end else begin
OutputDebugString(Pchar('Unknown Token: ' + CurrentToken));
end;
@ -1011,7 +1034,7 @@ end;
procedure TControlPoint.CalcBoundbox;
var
Points: TPointsXYArray;
Points: TPointsArray; //TPointsXYArray;
i, j: integer;
deltax, minx, maxx: double;
cntminx, cntmaxx: integer;
@ -1040,7 +1063,7 @@ begin
Prepare;
IterateXY(SUB_BATCH_SIZE, points);
IterateXYC(SUB_BATCH_SIZE, points);
LimitOutSidePoints := Round(0.05 * SUB_BATCH_SIZE);
@ -1127,7 +1150,7 @@ end;
function CalcUPRMagn(const cp: TControlPoint): double;
var
Points: TPointsXYArray;
Points: TPointsArray; //TPointsXYArray;
i, j: integer;
deltax, minx, maxx: double;
cntminx, cntmaxx: integer;
@ -1138,7 +1161,7 @@ var
begin
try
SetLength(Points, SUB_BATCH_SIZE);
cp.iterateXY(SUB_BATCH_SIZE, Points);
cp.iterateXYC(SUB_BATCH_SIZE, Points);
LimitOutSidePoints := Round(0.05 * SUB_BATCH_SIZE);
@ -1591,6 +1614,7 @@ begin
sl.Add(s);
sl.Add(Format('plotmode %d', [Ifthen(noPlot, 1, 0)]));
sl.Add(Format('retrace %d', [Ifthen(RetraceXform, 1, 0)]));
end;
DecimalSeparator := OldDecimalSperator;

View File

@ -1572,6 +1572,7 @@ object EditForm: TEditForm
Height = 17
Caption = 'Retrace xform'
TabOrder = 2
OnClick = chkRetraceClick
end
end
end

View File

@ -359,6 +359,7 @@ type
procedure mnuChaosSetAllClick(Sender: TObject);
procedure mnuLinkPostxformClick(Sender: TObject);
procedure chkXformSoloClick(Sender: TObject);
procedure chkRetraceClick(Sender: TObject);
private
TriangleView: TCustomDrawControl;
@ -836,6 +837,7 @@ begin
chkXformInvisible.Checked := noPlot;
chkXformSolo.Enabled := true;
chkRetrace.Enabled := not noPlot;
chkRetrace.Checked := RetraceXform;
if cp.soloXform >= 0 then begin
chkXformSolo.Checked := true;
chkXformSolo.Caption := Format('Solo transform #%d', [cp.soloXform + 1]);
@ -1384,7 +1386,7 @@ begin
assert(trkVarPreviewRange.position > 0);
assert(trkVarPreviewDensity.position > 0);
cp.xform[SelectedTriangle].prepare;
cp.xform[SelectedTriangle].Prepare;
n := trkVarPreviewRange.position * trkVarPreviewDensity.position * 5;
d1 := trkVarPreviewDensity.position * 5;
@ -4383,7 +4385,10 @@ procedure TEditForm.VEVarsDrawCell(Sender: TObject; ACol, ARow: Integer;
begin
if (ARow > NRLOCVAR) and not (gdSelected in State) then
begin
VEVars.canvas.brush.Color := $ffe0e0;
if Arow > NumBuiltinVars then
VEVars.canvas.brush.Color := $e0ffff
else
VEVars.canvas.brush.Color := $ffe0e0;
VEVars.canvas.fillRect(Rect);
VEVars.canvas.TextOut(Rect.Left+2, Rect.Top+2, VEVars.Cells[ACol,ARow]);
end;
@ -5000,5 +5005,19 @@ begin
end;
end;
procedure TEditForm.chkRetraceClick(Sender: TObject);
var
newValue: boolean;
begin
if (SelectedTriangle < Transforms) then begin
newValue := chkRetrace.Checked;
if cp.xform[SelectedTriangle].RetraceXform <> newValue then begin
MainForm.UpdateUndo;
cp.xform[SelectedTriangle].RetraceXform := newValue;
UpdateFlame(true);
end;
end;
end;
end.

View File

@ -42,7 +42,7 @@ const
RS_XO = 2;
RS_VO = 3;
AppVersionString = 'Apophysis 2.08 beta pre4.5';
AppVersionString = 'Apophysis 2.08 beta pre5';
type
TMouseMoveState = (msUsual, msZoomWindow, msZoomOutWindow, msZoomWindowMove,
@ -4248,10 +4248,18 @@ begin
v := Attributes.Value('plotmode');
if v <> '' then begin
if v = 'off' then
noPlot := true
else
noPlot := false;
if v = 'off' then begin
noPlot := true;
RetraceXform := false;
end
else if v = 'retrace' then begin
noPlot := false;
RetraceXform := true;
end
else begin
noPlot := false;
RetraceXform := false;
end;
end;
for i := 0 to NRVAR - 1 do

View File

@ -106,7 +106,7 @@ var
Bucket: PBucket32;
MapColor: PColorMapColor;
p: TCPPoint;
p, q: TCPPoint;
xf: TXForm;
begin
{$ifndef _ASM_}
@ -133,22 +133,38 @@ end;
xf := fcp.xform[0];//random(fcp.NumXForms)];
for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
if xf.RetraceXform then continue;
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.RetraceXform then begin
if xf.noPlot then continue;
if xf.noPlot then continue;
xf.NextPointTo(p, q);
px := p.x - camX0;
if (px < 0) or (px > camW) then continue;
py := p.y - camY0;
if (py < 0) or (py > camH) then continue;
px := q.x - camX0;
if (px < 0) or (px > camW) then continue;
py := q.y - camY0;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bhs * py)][Round(bws * px)];
MapColor := @ColorMap[Round(p.c * 255)];
Bucket := @buckets[Round(bhs * py)][Round(bws * px)];
MapColor := @ColorMap[Round(q.c * 255)];
end
else begin
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x - camX0;
if (px < 0) or (px > camW) then continue;
py := p.y - camY0;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bhs * py)][Round(bws * px)];
MapColor := @ColorMap[Round(p.c * 255)];
end;
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
@ -170,7 +186,7 @@ var
Bucket: PBucket32;
MapColor: PColorMapColor;
p: TCPPoint;
p, q: TCPPoint;
xf: TXForm;
begin
{$ifndef _ASM_}
@ -197,22 +213,38 @@ end;
xf := fcp.xform[0];//random(fcp.NumXForms)];
for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
if xf.RetraceXform then continue;
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.RetraceXform then begin
if xf.noPlot then continue;
if xf.noPlot then continue;
xf.NextPointTo(p, q);
px := p.x * cosa + p.y * sina + rcX;
if (px < 0) or (px > camW) then continue;
py := p.y * cosa - p.x * sina + rcY;
if (py < 0) or (py > camH) then continue;
px := q.x * cosa + q.y * sina + rcX;
if (px < 0) or (px > camW) then continue;
py := q.y * cosa - q.x * sina + rcY;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bhs * py)][Round(bws * px)];
MapColor := @ColorMap[Round(p.c * 255)];
Bucket := @buckets[Round(bhs * py)][Round(bws * px)];
MapColor := @ColorMap[Round(q.c * 255)];
end
else begin
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x * cosa + p.y * sina + rcX;
if (px < 0) or (px > camW) then continue;
py := p.y * cosa - p.x * sina + rcY;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bhs * py)][Round(bws * px)];
MapColor := @ColorMap[Round(p.c * 255)];
end;
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
@ -262,16 +294,25 @@ end;
xf := fcp.xform[0];//random(fcp.NumXForms)];
for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
if xf.RetraceXform then continue;
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.RetraceXform then begin
if xf.noPlot then continue;
if xf.noPlot then continue;
xf.NextPointTo(p, q);
finalXform.NextPoint(q);
end
else begin
xf.NextPoint(p);
finalXform.NextPointTo(p, q);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q);
end;
px := q.x - camX0;
if (px < 0) or (px > camW) then continue;
@ -328,16 +369,25 @@ end;
xf := fcp.xform[0];//random(fcp.NumXForms)];
for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
if xf.RetraceXform then continue;
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.RetraceXform then begin
if xf.noPlot then continue;
if xf.noPlot then continue;
xf.NextPointTo(p, q);
finalXform.NextPoint(q);
end
else begin
xf.NextPoint(p);
finalXform.NextPointTo(p, q);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q);
end;
px := q.x * cosa + q.y * sina + rcX;
if (px < 0) or (px > camW) then continue;

View File

@ -39,7 +39,7 @@ type
TXYpoint = record
x, y: double;
skip: boolean;
//skip: boolean;
end;
PXYpoint = ^TXYpoint;
@ -80,8 +80,9 @@ type
FFunctionList: array of TCalcFunction;
FCalcFunctionList: array of TCalcFunction;
FTx, FTy: double;
FPx, FPy: double;
FTx, FTy: double; // must remain in this order
FPx, FPy: double; // some asm code relies on this
FAngle: double;
FSinA: double;
FCosA: double;
@ -2190,7 +2191,9 @@ begin
Result := Result + '" ';
end;
if noPlot = true then
if RetraceXform then
Result := Result + 'plotmode="retrace" '
else if noPlot then
Result := Result + 'plotmode="off" ';
Result := Result + '/>';

View File

@ -8,6 +8,9 @@ uses
const
NRLOCVAR = 30;
var
NumBuiltinVars: integer;
function NrVar: integer;
function Varnames(const index: integer): String;
procedure RegisterVariation(Variation: TVariationLoader);
@ -26,7 +29,7 @@ var
VariationList: TList;
VariableNames: TStringlist;
loaderNum : integer;
///////////////////////////////////////////////////////////////////////////////
function NrVar: integer;
begin

View File

@ -223,6 +223,7 @@ var
name, msg: string;
PluginData : TPluginData;
begin
NumBuiltinVars := NRLOCVAR + GetNrRegisteredVariations;
// Try to find regular files matching *.dll in the plugins dir
if FindFirst('.\Plugins\*.dll', faAnyFile, searchResult) = 0 then
begin