chaos control tables for each transform

This commit is contained in:
zueuk 2008-07-25 13:30:14 +00:00
parent 77fcc571e3
commit 39adb9f697
13 changed files with 547 additions and 113 deletions

View File

@ -2,6 +2,7 @@
Flame screensaver Copyright (C) 2002 Ronald Hordijk Flame screensaver Copyright (C) 2002 Ronald Hordijk
Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -17,6 +18,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
} }
unit ControlPoint; unit ControlPoint;
interface interface
@ -27,8 +29,6 @@ uses
Classes, Windows, Cmap, XForm, XFormMan; Classes, Windows, Cmap, XForm, XFormMan;
const const
NXFORMS = 100;
SUB_BATCH_SIZE = 10000; SUB_BATCH_SIZE = 10000;
PROP_TABLE_SIZE = 1024; PROP_TABLE_SIZE = 1024;
PREFILTER_WHITE = (1 shl 26); PREFILTER_WHITE = (1 shl 26);
@ -88,6 +88,8 @@ type
finalXform: TXForm; finalXform: TXForm;
finalXformEnabled: boolean; finalXformEnabled: boolean;
useFinalXform: boolean; useFinalXform: boolean;
soloXform: integer;
Transparency: boolean; Transparency: boolean;
xform: array[0..NXFORMS] of TXForm; xform: array[0..NXFORMS] of TXForm;
@ -127,11 +129,13 @@ type
jitters: integer; jitters: integer;
gamma_treshold: double; gamma_treshold: double;
PropTable: array of TXForm;//Integer; // PropTable: array of TXForm;//Integer;
FAngle: Double; FAngle: Double;
FTwoColorDimensions: Boolean; FTwoColorDimensions: Boolean;
private private
invalidXform: TXForm;
function getppux: double; function getppux: double;
function getppuy: double; function getppuy: double;
@ -222,6 +226,8 @@ begin
for i := 0 to NXFORMS do begin for i := 0 to NXFORMS do begin
xform[i] := TXForm.Create; xform[i] := TXForm.Create;
end; end;
invalidXform := TXForm.Create;
soloXform := -1;
pulse[0][0] := 0; pulse[0][0] := 0;
pulse[0][1] := 60; pulse[0][1] := 60;
@ -278,6 +284,7 @@ var
begin begin
for i := 0 to NXFORMS do for i := 0 to NXFORMS do
xform[i].Free; xform[i].Free;
invalidXform.Free;
inherited; inherited;
end; end;
@ -289,10 +296,13 @@ var
LoopValue: double; LoopValue: double;
j: integer; j: integer;
TotValue: double; TotValue: double;
begin
SetLength(PropTable, PROP_TABLE_SIZE);
totValue := 0; k: integer;
tp: array[0..NXFORMS] of double;
begin
// SetLength(PropTable, PROP_TABLE_SIZE);
//totValue := 0;
n := NumXforms; n := NumXforms;
assert(n > 0); assert(n > 0);
@ -301,21 +311,45 @@ begin
useFinalXform := FinalXformEnabled and HasFinalXform; useFinalXform := FinalXformEnabled and HasFinalXform;
for i := 0 to n - 1 do begin for i := 0 to n - 1 do begin
xform[i].Prepare; xform[i].Prepare;
totValue := totValue + xform[i].density; //totValue := totValue + xform[i].density;
end;
invalidXform.PrepareInvalidXForm;
if soloXform >= 0 then begin
for i := 0 to n - 1 do xform[i].noPlot := true;
xform[soloXform].noPlot := false;
end; end;
LoopValue := 0; for k := 0 to n - 1 do begin
for i := 0 to PROP_TABLE_SIZE-1 do begin totValue := 0;
propsum := 0; SetLength(xform[k].PropTable, PROP_TABLE_SIZE);
j := -1;
repeat
inc(j);
propsum := propsum + xform[j].density;
until (propsum > LoopValue) or (j = n - 1);
PropTable[i] := xform[j];
LoopValue := LoopValue + TotValue / PROP_TABLE_SIZE;
end;
for i := 0 to n - 1 do begin
tp[i] := xform[i].density * xform[k].modWeights[i];
totValue := totValue + tp[i];
end;
if totValue > 0 then begin
LoopValue := 0;
for i := 0 to PROP_TABLE_SIZE-1 do begin
propsum := 0;
j := -1;
repeat
inc(j);
propsum := propsum + tp[j];//xform[j].density;
until (propsum > LoopValue) or (j = n - 1);
//assert(tp[j]<>0);
xform[k].PropTable[i] := xform[j];
LoopValue := LoopValue + TotValue / PROP_TABLE_SIZE;
end;
end
else begin
for i := 0 to PROP_TABLE_SIZE-1 do
xform[k].PropTable[i] := invalidXform;
end;
end;
end; end;
procedure TControlPoint.IterateXY(NrPoints: integer; var Points: TPointsXYArray); procedure TControlPoint.IterateXY(NrPoints: integer; var Points: TPointsXYArray);
@ -323,28 +357,44 @@ var
i: Integer; i: Integer;
px, py: double; px, py: double;
pPoint: PXYPoint; pPoint: PXYPoint;
xf: TXform;
begin begin
px := 2 * random - 1; px := 2 * random - 1;
py := 2 * random - 1; py := 2 * random - 1;
try try
for i := 0 to FUSE do xf := xform[0];//random(NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPointXY(px,py);
end;
pPoint := @Points[0]; pPoint := @Points[0];
if UseFinalXform then if UseFinalXform then
for i := 0 to NrPoints - 1 do begin for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
pPoint^.X := px; xf.NextPointXY(px,py);
pPoint^.Y := py; if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
pPoint^.X := px;
pPoint^.Y := py;
end;
finalXform.NextPointXY(pPoint^.X, pPoint^.y); finalXform.NextPointXY(pPoint^.X, pPoint^.y);
Inc(pPoint); Inc(pPoint);
end end
else else
for i := 0 to NrPoints - 1 do begin for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
pPoint.X := px; xf.NextPointXY(px,py);
pPoint.Y := py; if xf.noPlot then
pPoint^.x := MaxDouble // hack
else begin
pPoint.X := px;
pPoint.Y := py;
end;
Inc(pPoint); Inc(pPoint);
end end
except except
@ -359,6 +409,8 @@ var
i: Integer; i: Integer;
p: TCPPoint; p: TCPPoint;
pPoint: PCPPoint; pPoint: PCPPoint;
xf: TXform;
begin begin
{$if false} {$if false}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -381,23 +433,35 @@ end;
{$ifend} {$ifend}
try try
for i := 0 to FUSE do xf := xform[0];//random(NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
pPoint := @Points[0]; pPoint := @Points[0];
if UseFinalXform then if UseFinalXform then
for i := 0 to NrPoints - 1 do begin for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
finalXform.NextPointTo(p, pPoint^); xf.NextPoint(p);
if xf.noPlot then
pPoint^.x := MaxDouble // hack
else
finalXform.NextPointTo(p, pPoint^);
Inc(pPoint); Inc(pPoint);
end end
else else
for i := 0 to NrPoints - 1 do begin for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
pPoint^.x := p.x; xf.NextPoint(p);
pPoint^.y := p.y; if xf.noPlot then
pPoint^.c := p.c; pPoint^.x := MaxDouble // hack
else begin
pPoint^.x := p.x;
pPoint^.y := p.y;
pPoint^.c := p.c;
end;
Inc(pPoint); Inc(pPoint);
end end
except except
@ -461,6 +525,8 @@ var
//px, py, pc1, pc2: double; //px, py, pc1, pc2: double;
p: T2CPoint; p: T2CPoint;
CurrentPoint: P2Cpoint; CurrentPoint: P2Cpoint;
xf: TXform;
begin begin
p.x := 2 * random - 1; p.x := 2 * random - 1;
p.y := 2 * random - 1; p.y := 2 * random - 1;
@ -468,13 +534,17 @@ begin
p.c2 := random; p.c2 := random;
try try
for i := 0 to FUSE do xf := xform[random(NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(p);//px, py, pc1, pc2); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint2C(p);//px, py, pc1, pc2);
end;
CurrentPoint := @Points[0]; CurrentPoint := @Points[0];
if UseFinalXform then if UseFinalXform then
for i := 0 to NrPoints - 1 do begin for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(p);//px, py, pc1, pc2); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint2C(p);//px, py, pc1, pc2);
CurrentPoint.X := p.x; CurrentPoint.X := p.x;
CurrentPoint.Y := p.y; CurrentPoint.Y := p.y;
CurrentPoint.C1 := p.c1; CurrentPoint.C1 := p.c1;
@ -484,7 +554,8 @@ if UseFinalXform then
end end
else else
for i := 0 to NrPoints - 1 do begin for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint2C(p);
CurrentPoint.X := p.x; CurrentPoint.X := p.x;
CurrentPoint.Y := p.y; CurrentPoint.Y := p.y;
CurrentPoint.C1 := p.c1; CurrentPoint.C1 := p.c1;
@ -506,6 +577,8 @@ var
minx, maxx, miny, maxy: double; minx, maxx, miny, maxy: double;
Points: TPointsXYArray; Points: TPointsXYArray;
CurrentPoint: PXYPoint; CurrentPoint: PXYPoint;
xf: TXForm;
begin begin
Result := false; Result := false;
@ -518,12 +591,16 @@ begin
Prepare; Prepare;
try try
for i := 0 to FUSE do xf := xform[random(NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPointXY(px,py);
end;
CurrentPoint := @Points[0]; CurrentPoint := @Points[0];
for i := 0 to n-1 do begin for i := 0 to n-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPointXY(px,py);
CurrentPoint.X := px; CurrentPoint.X := px;
CurrentPoint.Y := py; CurrentPoint.Y := py;
Inc(CurrentPoint); Inc(CurrentPoint);
@ -580,6 +657,9 @@ begin
end else if AnsiCompareText(CurrentToken, 'finalxformenabled') = 0 then begin end else if AnsiCompareText(CurrentToken, 'finalxformenabled') = 0 then begin
Inc(ParsePos); Inc(ParsePos);
finalxformenabled := StrToInt(ParseValues[ParsePos]) <> 0; finalxformenabled := StrToInt(ParseValues[ParsePos]) <> 0;
end else if AnsiCompareText(CurrentToken, 'soloxform') = 0 then begin
Inc(ParsePos);
soloxform := StrToInt(ParseValues[ParsePos]);
end else if AnsiCompareText(CurrentToken, 'time') = 0 then begin end else if AnsiCompareText(CurrentToken, 'time') = 0 then begin
Inc(ParsePos); Inc(ParsePos);
time := StrToFloat(ParseValues[ParsePos]); time := StrToFloat(ParseValues[ParsePos]);
@ -766,6 +846,23 @@ begin
Inc(i); Inc(i);
end; end;
end else if AnsiCompareText(CurrentToken, 'chaos') = 0 then begin
i := 0;
while true do begin
if (ParsePos + 1) >= ParseValues.Count then
break;
if ParseValues[ParsePos + 1][1] in ['a'..'z', 'A'..'Z'] then
break;
Inc(ParsePos);
v := StrToFloat(ParseValues[ParsePos]);
xform[CurrentXForm].modWeights[i] := v;
Inc(i);
end;
end else if AnsiCompareText(CurrentToken, 'plotmode') = 0 then begin
Inc(ParsePos);
xform[CurrentXForm].noPlot := StrToInt(ParseValues[ParsePos]) <> 0;
end else begin end else begin
OutputDebugString(Pchar('Unknown Token: ' + CurrentToken)); OutputDebugString(Pchar('Unknown Token: ' + CurrentToken));
end; end;
@ -1456,8 +1553,9 @@ begin
sl.add(format('brightness %f gamma %f vibrancy %f hue_rotation %f cmap_inter %d', sl.add(format('brightness %f gamma %f vibrancy %f hue_rotation %f cmap_inter %d',
[brightness * BRIGHT_ADJUST, gamma, vibrancy, hue_rotation, cmap_inter])); [brightness * BRIGHT_ADJUST, gamma, vibrancy, hue_rotation, cmap_inter]));
sl.add(format('finalxformenabled %d', [ifthen(finalxformenabled, 1, 0)])); sl.add(format('finalxformenabled %d', [ifthen(finalxformenabled, 1, 0)]));
sl.add(format('soloxform %d', [soloXform]));
for i := 0 to NXFORMS do for i := 0 to NumXForms+1 do //NXFORMS do
with xform[i] do begin with xform[i] do begin
//if density = 0 then continue; - FinalXform has weight=0 //if density = 0 then continue; - FinalXform has weight=0
@ -1485,6 +1583,15 @@ begin
sl.Add('postxswap 1') sl.Add('postxswap 1')
else else
sl.Add('postxswap 0'); sl.Add('postxswap 0');
s := 'chaos';
for j := 0 to NumXForms+1 do begin
s := s + format(' %g', [modWeights[j]]);
end;
sl.Add(s);
sl.Add(Format('plotmode %d', [Ifthen(noPlot, 1, 0)]));
end; end;
DecimalSeparator := OldDecimalSperator; DecimalSeparator := OldDecimalSperator;
end; end;

View File

@ -198,6 +198,7 @@ end;
procedure TFullscreenForm.OnProgress(prog: double); procedure TFullscreenForm.OnProgress(prog: double);
begin begin
prog := (Renderer.Slice + Prog) / Renderer.NrSlices; prog := (Renderer.Slice + Prog) / Renderer.NrSlices;
Canvas.Lock;
try try
if prog >= 1 then if prog >= 1 then
begin begin
@ -212,7 +213,8 @@ begin
Canvas.Brush.Color := clBlack; Canvas.Brush.Color := clBlack;
Canvas.Fillrect(Rect(7 + Round(prog * (ClientWidth - 14)), ClientHeight - 13, ClientWidth - 7, ClientHeight - 7)); Canvas.Fillrect(Rect(7 + Round(prog * (ClientWidth - 14)), ClientHeight - 13, ClientWidth - 7, ClientHeight - 7));
end; end;
except finally
Canvas.Unlock;
end; end;
Application.ProcessMessages; Application.ProcessMessages;
end; end;

View File

@ -1,7 +1,7 @@
{ {
Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007 Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -42,7 +42,7 @@ const
RS_XO = 2; RS_XO = 2;
RS_VO = 3; RS_VO = 3;
AppVersionString = 'Apophysis 2.07 beta'; AppVersionString = 'Apophysis 2.08 beta pre4.5';
type type
TMouseMoveState = (msUsual, msZoomWindow, msZoomOutWindow, msZoomWindowMove, TMouseMoveState = (msUsual, msZoomWindow, msZoomOutWindow, msZoomWindowMove,
@ -4238,6 +4238,22 @@ begin
p[2][1] := StrToFloat(Tokens[5]); p[2][1] := StrToFloat(Tokens[5]);
end; end;
v := Attributes.Value('chaos');
if v <> '' then begin
GetTokens(v, tokens);
for i := 0 to Tokens.Count-1 do
modWeights[i] := Abs(StrToFloat(Tokens[i]));
end;
//else for i := 0 to NXFORMS-1 do modWeights[i] := 1;
v := Attributes.Value('plotmode');
if v <> '' then begin
if v = 'off' then
noPlot := true
else
noPlot := false;
end;
for i := 0 to NRVAR - 1 do for i := 0 to NRVAR - 1 do
begin begin
vars[i] := 0; vars[i] := 0;

View File

@ -2,6 +2,7 @@
Flame screensaver Copyright (C) 2002 Ronald Hordijk Flame screensaver Copyright (C) 2002 Ronald Hordijk
Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -106,6 +107,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p: TCPPoint; p: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -128,11 +130,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x - camX0; px := p.x - camX0;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -163,6 +171,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p: TCPPoint; p: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -185,11 +194,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x * cosa + p.y * sina + rcX; px := p.x * cosa + p.y * sina + rcX;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -221,6 +236,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -243,11 +259,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x - camX0; px := q.x - camX0;
@ -279,6 +302,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -301,11 +325,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x * cosa + q.y * sina + rcX; px := q.x * cosa + q.y * sina + rcX;

View File

@ -2,6 +2,7 @@
Flame screensaver Copyright (C) 2002 Ronald Hordijk Flame screensaver Copyright (C) 2002 Ronald Hordijk
Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -133,6 +134,7 @@ var
MapColor: ^TFloatColor; MapColor: ^TFloatColor;
p: TCPPoint; p: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -155,11 +157,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x - camX0; px := p.x - camX0;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -192,6 +200,7 @@ var
MapColor: ^TFloatColor; MapColor: ^TFloatColor;
p: TCPPoint; p: TCPPoint;
xf: TXform;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -214,11 +223,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x * cosa + p.y * sina + rcX; px := p.x * cosa + p.y * sina + rcX;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -252,6 +267,7 @@ var
MapColor: ^TFloatColor; MapColor: ^TFloatColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -274,11 +290,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x - camX0; px := q.x - camX0;
@ -312,6 +335,7 @@ var
MapColor: ^TFloatColor; MapColor: ^TFloatColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -334,11 +358,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x * cosa + q.y * sina + rcX; px := q.x * cosa + q.y * sina + rcX;

View File

@ -2,6 +2,7 @@
Flame screensaver Copyright (C) 2002 Ronald Hordijk Flame screensaver Copyright (C) 2002 Ronald Hordijk
Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -126,6 +127,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p: TCPPoint; p: TCPPoint;
xf: TXForm;
t: int64; t: int64;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
@ -149,11 +151,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x - camX0; px := p.x - camX0;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -212,6 +220,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p: TCPPoint; p: TCPPoint;
xf: TXForm;
t: int64; t: int64;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
@ -235,11 +244,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x * cosa + p.y * sina + rcX; px := p.x * cosa + p.y * sina + rcX;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -299,6 +314,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
t: int64; t: int64;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
@ -322,11 +338,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x - camX0; px := q.x - camX0;
@ -386,6 +409,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
t: int64; t: int64;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
@ -409,11 +433,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x * cosa + q.y * sina + rcX; px := q.x * cosa + q.y * sina + rcX;
@ -465,7 +496,7 @@ end;
end; end;
end; end;
// -- { TRenderer32MM } ------------------------------------------------------- // -- { TRenderer48MM } -------------------------------------------------------
procedure TRenderer48MM.CalcBufferSize; procedure TRenderer48MM.CalcBufferSize;
begin begin

View File

@ -2,6 +2,7 @@
Flame screensaver Copyright (C) 2002 Ronald Hordijk Flame screensaver Copyright (C) 2002 Ronald Hordijk
Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -131,6 +132,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p: TCPPoint; p: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -153,11 +155,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x - camX0; px := p.x - camX0;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -188,6 +196,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p: TCPPoint; p: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -210,11 +219,17 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
px := p.x * cosa + p.y * sina + rcX; px := p.x * cosa + p.y * sina + rcX;
if (px < 0) or (px > camW) then continue; if (px < 0) or (px > camW) then continue;
@ -246,6 +261,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -268,11 +284,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x - camX0; px := q.x - camX0;
@ -304,6 +327,7 @@ var
MapColor: PColorMapColor; MapColor: PColorMapColor;
p, q: TCPPoint; p, q: TCPPoint;
xf: TXForm;
begin begin
{$ifndef _ASM_} {$ifndef _ASM_}
p.x := 2 * random - 1; p.x := 2 * random - 1;
@ -326,11 +350,18 @@ end;
{$endif} {$endif}
try try
for i := 0 to FUSE do xf := fcp.xform[0];//random(fcp.NumXForms)];
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); for i := 0 to FUSE do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
end;
for i := 0 to SUB_BATCH_SIZE-1 do begin for i := 0 to SUB_BATCH_SIZE-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p); xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p);
if xf.noPlot then continue;
finalXform.NextPointTo(p, q); finalXform.NextPointTo(p, q);
px := q.x * cosa + q.y * sina + rcX; px := q.x * cosa + q.y * sina + rcX;

View File

@ -50,6 +50,8 @@ begin
finalXform.Prepare; finalXform.Prepare;
useFinalXform := fcp.FinalXformEnabled and fcp.HasFinalXform; useFinalXform := fcp.FinalXformEnabled and fcp.HasFinalXform;
fcp.Prepare;
{
for i := 0 to n - 1 do begin for i := 0 to n - 1 do begin
fcp.xform[i].Prepare; fcp.xform[i].Prepare;
totValue := totValue + fcp.xform[i].density; totValue := totValue + fcp.xform[i].density;
@ -66,6 +68,7 @@ begin
PropTable[i] := fcp.xform[j]; PropTable[i] := fcp.xform[j];
LoopValue := LoopValue + TotValue / PROP_TABLE_SIZE; LoopValue := LoopValue + TotValue / PROP_TABLE_SIZE;
end; end;
}
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -511,14 +511,14 @@ begin
Result.xform[i].c[2][0] := random * 2 - 1; Result.xform[i].c[2][0] := random * 2 - 1;
Result.xform[i].c[2][1] := random * 2 - 1; Result.xform[i].c[2][1] := random * 2 - 1;
end; end;
for i := 0 to NXFORMS - 1 do for i := 0 to 100-1 do //NXFORMS - 1 do
Result.xform[i].density := 0; Result.xform[i].density := 0;
for i := 0 to Transforms - 1 do for i := 0 to Transforms - 1 do
Result.xform[i].density := 1 / Transforms; Result.xform[i].density := 1 / Transforms;
SetVariation(Result); SetVariation(Result);
end; end;
9: begin 9: begin
for i := 0 to NXFORMS - 1 do for i := 0 to 100-1 do //NXFORMS - 1 do
Result.xform[i].density := 0; Result.xform[i].density := 0;
for i := 0 to Transforms - 1 do for i := 0 to Transforms - 1 do
Result.xform[i].density := 1 / Transforms; Result.xform[i].density := 1 / Transforms;

View File

@ -180,6 +180,11 @@ type
procedure GetTransformVariProc(AMachine: TatVirtualMachine); procedure GetTransformVariProc(AMachine: TatVirtualMachine);
procedure SetTransformVariProc(AMachine: TatVirtualMachine); procedure SetTransformVariProc(AMachine: TatVirtualMachine);
procedure GetTransformChaosProc(AMachine: TatVirtualMachine);
procedure SetTransformChaosProc(AMachine: TatVirtualMachine);
procedure GetTransformPlotModeProc(AMachine: TatVirtualMachine);
procedure SetTransformPlotModeProc(AMachine: TatVirtualMachine);
procedure GetTransformColorProc(AMachine: TatVirtualMachine); procedure GetTransformColorProc(AMachine: TatVirtualMachine);
procedure SetTransformColorProc(AMachine: TatVirtualMachine); procedure SetTransformColorProc(AMachine: TatVirtualMachine);
procedure GetTransformWeightProc(AMachine: TatVirtualMachine); procedure GetTransformWeightProc(AMachine: TatVirtualMachine);
@ -2717,6 +2722,46 @@ begin
end; end;
end; end;
procedure TScriptEditor.GetTransformChaosProc(AMachine: TatVirtualMachine);
begin
with AMachine do
ReturnOutPutArg(cp.xform[ActiveTransform].modWeights[Integer(GetArrayIndex(0))]);
end;
procedure TScriptEditor.SetTransformChaosProc(AMachine: TatVirtualMachine);
var
v: double;
i: integer;
begin
with AMachine do
begin
v := GetInputArgAsFloat(0);
i := GetArrayIndex(0);
if (i >= 0) and (i < NumTransforms) then
cp.xform[ActiveTransform].modWeights[i] := v;
end;
end;
procedure TScriptEditor.GetTransformPlotModeProc(AMachine: TatVirtualMachine);
begin
with AMachine do
if cp.xform[ActiveTransform].noPlot then
ReturnOutPutArg(1)
else
ReturnOutPutArg(0);
end;
procedure TScriptEditor.SetTransformPlotModeProc(AMachine: TatVirtualMachine);
var
v: integer;
begin
with AMachine do
begin
v := GetInputArgAsInteger(0);
cp.xform[ActiveTransform].noPlot := v <> 0;
end;
end;
// -- vars as props -- // -- vars as props --
procedure TScriptEditor.GetTransformVariationProc(AMachine: TatVirtualMachine); procedure TScriptEditor.GetTransformVariationProc(AMachine: TatVirtualMachine);
@ -3197,6 +3242,7 @@ begin
DefineProp('f', tkFloat, GetTransformFProc, SetTransformFProc); DefineProp('f', tkFloat, GetTransformFProc, SetTransformFProc);
DefineProp('Variation', tkFloat, GetTransformVarProc, SetTransformVarProc, nil, false, 1); DefineProp('Variation', tkFloat, GetTransformVarProc, SetTransformVarProc, nil, false, 1);
DefineProp('Variable', tkFloat, GetTransformVariProc, SetTransformVariProc, nil, false, 1); DefineProp('Variable', tkFloat, GetTransformVariProc, SetTransformVariProc, nil, false, 1);
DefineProp('Chaos', tkFloat, GetTransformChaosProc, SetTransformChaosProc, nil, false, 1);
end; end;
Scripter.AddObject('Transform', Transform); Scripter.AddObject('Transform', Transform);

View File

@ -1,3 +1,24 @@
{
Flame screensaver Copyright (C) 2002 Ronald Hordijk
Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}
unit XForm; unit XForm;
interface interface
@ -7,15 +28,18 @@ uses
const const
MAX_WEIGHT = 1000.0; MAX_WEIGHT = 1000.0;
NXFORMS = 100;
type type
TCPpoint = record TCPpoint = record
x, y, c: double; x, y, c: double;
//invisible: boolean;
end; end;
PCPpoint = ^TCPpoint; PCPpoint = ^TCPpoint;
TXYpoint = record TXYpoint = record
x, y: double; x, y: double;
skip: boolean;
end; end;
PXYpoint = ^TXYpoint; PXYpoint = ^TXYpoint;
@ -40,15 +64,21 @@ type
c00, c01, c10, c11, c20, c21: double;// unnecessary duplicated variables c00, c01, c10, c11, c20, c21: double;// unnecessary duplicated variables
p00, p01, p10, p11, p20, p21: double;// :-) p00, p01, p10, p11, p20, p21: double;// :-)
postXswap: boolean; postXswap: boolean;
noPlot: boolean;
RetraceXform: boolean;
// nx,ny,x,y: double; // nx,ny,x,y: double;
// script: TatPascalScripter; // script: TatPascalScripter;
modWeights: array [0..NXFORMS] of double;
PropTable: array of TXForm;
Orientationtype: integer; Orientationtype: integer;
private private
FNrFunctions: Integer; FNrFunctions: Integer;
FFunctionList: array of TCalcFunction; FFunctionList: array of TCalcFunction;
FCalcFunctionList: array{[0..64]} of TCalcFunction; FCalcFunctionList: array of TCalcFunction;
FTx, FTy: double; FTx, FTy: double;
FPx, FPy: double; FPx, FPy: double;
@ -74,6 +104,7 @@ type
procedure PrecalcSinCos; procedure PrecalcSinCos;
procedure PrecalcAll; procedure PrecalcAll;
procedure DoPostTransform; procedure DoPostTransform;
procedure DoInvalidOperation;
procedure Linear; // var[0] procedure Linear; // var[0]
procedure Sinusoidal; // var[1] procedure Sinusoidal; // var[1]
@ -104,6 +135,7 @@ type
procedure Noise; // var[26] procedure Noise; // var[26]
procedure Blur; // var[27] procedure Blur; // var[27]
procedure Gaussian; // var[28] procedure Gaussian; // var[28]
procedure PreBlur; // var[29]
function Mul33(const M1, M2: TMatrix): TMatrix; function Mul33(const M1, M2: TMatrix): TMatrix;
function Identity: TMatrix; function Identity: TMatrix;
@ -116,11 +148,11 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure Clear; procedure Clear;
procedure Prepare; procedure Prepare;
procedure PrepareInvalidXForm;
procedure Assign(Xform: TXForm); procedure Assign(Xform: TXForm);
procedure NextPoint(var px, py, pc: double); overload; procedure NextPoint(var CPpoint: TCPpoint);
procedure NextPoint(var CPpoint: TCPpoint); overload;
procedure NextPointTo(var CPpoint, ToPoint: TCPpoint); procedure NextPointTo(var CPpoint, ToPoint: TCPpoint);
procedure NextPointXY(var px, py: double); procedure NextPointXY(var px, py: double);
procedure NextPoint2C(var p: T2CPoint); procedure NextPoint2C(var p: T2CPoint);
@ -196,6 +228,12 @@ begin
vars[0] := 1; vars[0] := 1;
for i := 1 to High(vars) do for i := 1 to High(vars) do
vars[i] := 0; vars[i] := 0;
for i := 0 to NXFORMS do
modWeights[i] := 1;
noPlot := false;
RetraceXform := false;
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -235,6 +273,15 @@ begin
// CalculateLength := False; // CalculateLength := False;
CalculateSinCos := (vars[9] <> 0.0) or (vars[11] <> 0.0) or (vars[19] <> 0.0) or (vars[21] <> 0.0); CalculateSinCos := (vars[9] <> 0.0) or (vars[11] <> 0.0) or (vars[19] <> 0.0) or (vars[21] <> 0.0);
// Pre- variations
for i := 0 to NrVar - 1 do begin
if (vars[i] <> 0.0) and (LeftStr(Varnames(i), 4) = 'pre_') then begin
FCalcFunctionList[FNrFunctions] := FFunctionList[i];
Inc(FNrFunctions);
end;
end;
// Precalc must be called after pre- vars
if CalculateAngle or CalculateSinCos then if CalculateAngle or CalculateSinCos then
begin begin
if CalculateAngle and CalculateSinCos then if CalculateAngle and CalculateSinCos then
@ -246,14 +293,6 @@ begin
Inc(FNrFunctions); Inc(FNrFunctions);
end; end;
// Pre- variations
for i := 0 to NrVar - 1 do begin
if (vars[i] <> 0.0) and (LeftStr(Varnames(i), 4) = 'pre_') then begin
FCalcFunctionList[FNrFunctions] := FFunctionList[i];
Inc(FNrFunctions);
end;
end;
// Normal variations // Normal variations
for i := 0 to NrVar - 1 do begin for i := 0 to NrVar - 1 do begin
if (vars[i] <> 0.0) then begin if (vars[i] <> 0.0) then begin
@ -336,6 +375,23 @@ begin
*) *)
end; end;
procedure TXForm.PrepareInvalidXForm;
begin
c00 := 1;
c01 := 0;
c10 := 0;
c11 := 1;
c20 := 0;
c21 := 0;
colorC1 := 1;
colorC2 := 0;
FNrFunctions := 1;
SetLength(FCalcFunctionList, 1);
FCalcFunctionList[0] := DoInvalidOperation;
end;
procedure TXForm.PrecalcAngle; procedure TXForm.PrecalcAngle;
{$ifndef _ASM_} {$ifndef _ASM_}
begin begin
@ -436,6 +492,11 @@ asm
{$endif} {$endif}
end; end;
procedure TXForm.DoInvalidOperation;
begin
raise EMathError.Create('');
end;
//--0--//////////////////////////////////////////////////////////////////////// //--0--////////////////////////////////////////////////////////////////////////
procedure TXForm.Linear; procedure TXForm.Linear;
{$ifndef _ASM_} {$ifndef _ASM_}
@ -1615,8 +1676,54 @@ asm
{$endif} {$endif}
end; end;
//--29--///////////////////////////////////////////////////////////////////////
procedure TXForm.PreBlur;
{$ifndef _ASM_}
var
r, sina, cosa: double;
begin
SinCos(random * 2*pi, sina, cosa);
r := vars[29] * (gauss_rnd[0] + gauss_rnd[1] + gauss_rnd[2] + gauss_rnd[3] - 2);
gauss_rnd[gauss_N] := random;
gauss_N := (gauss_N+1) and $3;
FTx := FTx + r * cosa;
FTy := FTy + r * sina;
{$else}
asm
fld qword ptr [ebx + gauss_rnd]
fadd qword ptr [ebx + gauss_rnd+8]
fadd qword ptr [ebx + gauss_rnd+16]
fadd qword ptr [ebx + gauss_rnd+24]
fld1
fadd st,st
fsubp st(1),st
mov edx, [ebx + vars]
fmul qword ptr [edx + 29*8]
call System.@RandExt
mov edx, [ebx + gauss_N]
fst qword ptr [ebx + gauss_rnd + edx*8]
inc edx
and edx,$03
mov [eax + gauss_N], edx
fadd st, st
fldpi
fmulp
fsincos
fmul st, st(2)
fadd qword ptr [ebx + FTx]
fstp qword ptr [ebx + FTx]
fmulp
fadd qword ptr [ebx + FTy]
fstp qword ptr [ebx + FTy]
fwait
{$endif}
end;
//***************************************************************************// //***************************************************************************//
(*
procedure TXForm.NextPoint(var px, py, pc: double); procedure TXForm.NextPoint(var px, py, pc: double);
var var
i: Integer; i: Integer;
@ -1640,6 +1747,7 @@ begin
px := FPx; px := FPx;
py := FPy; py := FPy;
end; end;
*)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
procedure TXForm.NextPoint(var CPpoint: TCPpoint); procedure TXForm.NextPoint(var CPpoint: TCPpoint);
@ -1799,6 +1907,9 @@ begin
px := FPx; px := FPx;
py := FPy; py := FPy;
// if PlotMode <> keepPlot then
// skip := (PlotMode = neverPlot);
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -1981,6 +2092,7 @@ begin
FFunctionList[26] := Noise; FFunctionList[26] := Noise;
FFunctionList[27] := Blur; FFunctionList[27] := Blur;
FFunctionList[28] := Gaussian; FFunctionList[28] := Gaussian;
FFunctionList[29] := PreBlur;
//registered //registered
// for i := 0 to High(FRegVariations) do // for i := 0 to High(FRegVariations) do
@ -2028,6 +2140,12 @@ begin
FRegVariations[i].SetVariable(Name, Value); FRegVariations[i].SetVariable(Name, Value);
end; end;
end; end;
for i := 0 to 100 do
modWeights[i] := xform.modWeights[i];
noPlot := xform.noPlot;
RetraceXform := xform.RetraceXform;
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -2036,10 +2154,11 @@ var
i, j: integer; i, j: integer;
Name: string; Name: string;
Value: double; Value: double;
numChaos: integer;
begin begin
result := Format(' <xform weight="%g" color="%g" ', [density, color]); result := Format(' <xform weight="%g" color="%g" ', [density, color]);
if symmetry <> 0 then result := result + format('symmetry="%g" ', [symmetry]); if symmetry <> 0 then result := result + format('symmetry="%g" ', [symmetry]);
for i := 0 to nrvar - 1 do begin for i := 0 to nrvar - 1 do begin
if vars[i] <> 0 then if vars[i] <> 0 then
Result := Result + varnames(i) + format('="%g" ', [vars[i]]); Result := Result + varnames(i) + format('="%g" ', [vars[i]]);
@ -2058,6 +2177,22 @@ begin
end; end;
end; end;
numChaos := -1;
for i := NXFORMS-1 downto 0 do
if modWeights[i] <> 1 then begin
numChaos := i;
break;
end;
if numChaos >= 0 then begin
Result := Result + 'chaos="';
for i := 0 to numChaos do
Result := Result + Format('%g ', [modWeights[i]]);
Result := Result + '" ';
end;
if noPlot = true then
Result := Result + 'plotmode="off" ';
Result := Result + '/>'; Result := Result + '/>';
end; end;

View File

@ -6,7 +6,7 @@ uses
BaseVariation; BaseVariation;
const const
NRLOCVAR = 29; NRLOCVAR = 30;
function NrVar: integer; function NrVar: integer;
function Varnames(const index: integer): String; function Varnames(const index: integer): String;
@ -65,7 +65,8 @@ const
'cylinder', 'cylinder',
'noise', 'noise',
'blur', 'blur',
'gaussian_blur' 'gaussian_blur',
'pre_blur'
); );
begin begin
if Index < NRLOCVAR then if Index < NRLOCVAR then

View File

@ -1,7 +1,7 @@
{ {
Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2007 Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -17,12 +17,12 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
} }
{ {
Variation Plugin DLL support for Apophysis: Variation Plugin DLL support for Apophysis:
Generic Plugin Support Unit Generic Plugin Support Unit
Started by Jed Kelsey, June 2007 Started by Jed Kelsey, June 2007
Portions Copyright (C) 2008 Joel Faber Portions Copyright (C) 2008 Joel Faber