Added transform syncronization, an animation module and made the app work faster

This commit is contained in:
Alice Vital
2022-06-23 13:22:32 +03:00
parent 25a72c3c86
commit b1552d0ebc
98 changed files with 11657 additions and 7788 deletions

View File

@ -10,13 +10,13 @@ uses
type
TVariationAffine3D = class(TBaseVariation)
private
affine3D_a00, affine3D_a01, affine3D_a02,
affine3D_a10, affine3D_a11, affine3D_a12,
affine3D_a20, affine3D_a21, affine3D_a22,
affine3D_bx, affine3D_by, affine3D_bz: double;
x0, y0, z0: double;
affine3D_a00, affine3D_a01, affine3D_a02,
affine3D_a10, affine3D_a11, affine3D_a12,
affine3D_a20, affine3D_a21, affine3D_a22,
affine3D_bx, affine3D_by, affine3D_bz: double;
x0, y0, z0: double;
affine3D_mode: byte;
procedure CalcPre;
procedure CalcPre;
procedure CalcPost;
public
constructor Create;
@ -53,13 +53,13 @@ end;
procedure TVariationAffine3D.CalcPre;
var x, y, z, dn: double;
begin
x := affine3D_a00 * FTx^ - affine3D_a01 * FTy^ + affine3D_a02 * FTz^ + affine3D_bx;
y := -(affine3D_a10 * FTx^ - affine3D_a11 * FTy^ + affine3D_a12 * FTz^ + affine3D_by);
x := affine3D_a00 * FTx^ - affine3D_a01 * FTy^ + affine3D_a02 * FTz^ + affine3D_bx;
y := -(affine3D_a10 * FTx^ - affine3D_a11 * FTy^ + affine3D_a12 * FTz^ + affine3D_by);
z := affine3D_a20 * FTx^ - affine3D_a21 * FTy^ + affine3D_a22 * FTz^ + affine3D_bz;
FTx^ := VVAR * x;
FTy^ := VVAR * y;
FTz^ := VVAR * z;
FTy^ := VVAR * y;
FTz^ := VVAR * z;
dn := hypot(x - x0, y - y0, z - z0);
if (dn <> 0) then color^ := abs(cos(hypot(x - x0, y - y0) / dn))
@ -70,13 +70,13 @@ procedure TVariationAffine3D.CalcFunction;
var x, y, z, dn: double;
begin
x := affine3D_a00 * FTx^ - affine3D_a01 * FTy^ + affine3D_a02 * FTz^ + affine3D_bx;
y := -(affine3D_a10 * FTx^ - affine3D_a11 * FTy^ + affine3D_a12 * FTz^ + affine3D_by);
x := affine3D_a00 * FTx^ - affine3D_a01 * FTy^ + affine3D_a02 * FTz^ + affine3D_bx;
y := -(affine3D_a10 * FTx^ - affine3D_a11 * FTy^ + affine3D_a12 * FTz^ + affine3D_by);
z := affine3D_a20 * FTx^ - affine3D_a21 * FTy^ + affine3D_a22 * FTz^ + affine3D_bz;
FPx^ := FPx^ + VVAR * x;
FPy^ := FPy^ + VVAR * y;
FPz^ := FPz^ + VVAR * z;
FPx^ := FPx^ + VVAR * x;
FPy^ := FPy^ + VVAR * y;
FPz^ := FPz^ + VVAR * z;
dn := hypot(x - x0, y - y0, z - z0);
if (dn <> 0) then color^ := abs(cos(hypot(x - x0, y - y0) / dn))
@ -87,13 +87,13 @@ procedure TVariationAffine3D.CalcPost;
var x, y, z, dn: double;
begin
x := affine3D_a00 * FPx^ - affine3D_a01 * FPy^ + affine3D_a02 * FPz^ + affine3D_bx;
y := -(affine3D_a10 * FPx^ - affine3D_a11 * FPy^ + affine3D_a12 * FPz^ + affine3D_by);
x := affine3D_a00 * FPx^ - affine3D_a01 * FPy^ + affine3D_a02 * FPz^ + affine3D_bx;
y := -(affine3D_a10 * FPx^ - affine3D_a11 * FPy^ + affine3D_a12 * FPz^ + affine3D_by);
z := affine3D_a20 * FPx^ - affine3D_a21 * FPy^ + affine3D_a22 * FPz^ + affine3D_bz;
FPx^ := VVAR * x;
FPy^ := VVAR * y;
FPz^ := VVAR * z;
FPx^ := VVAR * x;
FPy^ := VVAR * y;
FPz^ := VVAR * z;
dn := hypot(x - x0, y - y0, z - z0);
if (dn <> 0) then color^ := abs(cos(hypot(x - x0, y - y0) / dn))
@ -204,6 +204,7 @@ begin
Result := True;
end
end;
function TVariationAffine3D.ResetVariable(const Name: string): boolean;
begin
Result := False;

View File

@ -40,7 +40,7 @@ procedure TVariationCothSpiral.CalcFunction;
var
t, aux, sn, cn, snh, cnh: double;
begin
t := (random - 0.5) * 6.28318530717959;
t := (random - 0.5) * PI2;
SinCos(ta * t, sn, cn);
SinhCosh(t, snh, cnh);

View File

@ -35,8 +35,7 @@ const
var_c1_name='curl_c1';
var_c2_name='curl_c2';
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -7,15 +7,14 @@ interface
uses
BaseVariation, XFormMan;
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}
type
TVariationDisc2 = class(TBaseVariation)
private
rot, add, c, k, sinadd, cosadd: double;
rot, add, p, k, sinadd, cosadd: double;
public
constructor Create;
@ -49,7 +48,7 @@ end;
procedure TVariationDisc2.Prepare;
var t: double;
begin
c := vvar / PI;
p := vvar / PI;
k := rot * PI;
SinCos(add, sinadd, cosadd);
cosadd := cosadd - 1;
@ -73,7 +72,7 @@ var
r, sinr, cosr: extended;
begin
SinCos(k * (FTx^ + FTy^), sinr, cosr);
r := c * arctan2(FTx^, FTy^);
r := p * arctan2(FTx^, FTy^);
FPx^ := FPx^ + (sinr + cosadd) * r;
FPy^ := FPy^ + (cosr + sinadd) * r;
{$else}
@ -82,7 +81,7 @@ asm
fld qword ptr [edx]
fld qword ptr [edx + 8]
fpatan
fmul qword ptr [eax + c]
fmul qword ptr [eax + p]
fld qword ptr [edx]
fadd qword ptr [edx + 8]
fmul qword ptr [eax + k]

View File

@ -6,8 +6,7 @@ interface
uses
BaseVariation, XFormMan;
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -5,6 +5,7 @@
Apophysis "3D hack" Copyright (C) 2007-2008 Peter Sdobnov
Apophysis "7X" Copyright (C) 2009-2010 Georg Kiehne
Apophysis AV "Phoenix Edition" Copyright (C) 2021-2022 Alice V. Koryagina
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
@ -40,9 +41,8 @@ interface
uses
BaseVariation, XFormMan, Settings, // Translation,
Classes, //TStrings/TStringList
SysUtils, //FindFirst/FindNext/FindClose
Forms; //MessageBox
Classes, //TFileStream
SysUtils; //FindFirst/FindNext/FindClose
type
TPluginVariationClass = class of TPluginVariation;
@ -108,10 +108,10 @@ type
PluginData : TPluginData;
end;
procedure InitializePlugins;
//procedure InitializePlugins;
const CurrentPlatform =
{$ifdef Apo7X64}
{$ifdef CPUX64}
$00000040
{$else}
$00000020
@ -122,7 +122,7 @@ const CurrentPlatform =
implementation
uses
Windows, //LoadLibrary
Windows, //LoadLibrary / MessageBox
Global;
{ TPluginVariation }
@ -206,31 +206,31 @@ begin
Result := '';
end;
///////////////////////////////////////////////////////////////////////////////
{ //////////////////////////////////////////////////////////////////////////}
function TPluginVariation.GetNrVariables: integer;
begin
Result := PluginData.PluginVarGetNrVariables;
end;
///////////////////////////////////////////////////////////////////////////////
{////////////////////////////////////////////////////////////////////////////}
function TPluginVariation.GetVariableNameAt(const Index: integer): string;
begin
Result := String(PluginData.PluginVarGetVariableNameAt(Index));
end;
///////////////////////////////////////////////////////////////////////////////
{////////////////////////////////////////////////////////////////////////////}
function TPluginVariation.SetVariable(const Name: string; var value: double): boolean;
begin
Result := PluginData.PluginVarSetVariable(MyVariation,PAnsiChar(AnsiString(Name)),value);
end;
///////////////////////////////////////////////////////////////////////////////
{////////////////////////////////////////////////////////////////////////////}
function TPluginVariation.GetVariable(const Name: string; var value: double): boolean;
begin
Result := PluginData.PluginVarGetVariable(MyVariation,PAnsiChar(AnsiString(Name)),value);
end;
///////////////////////////////////////////////////////////////////////////////
{ ////////////////////////////////////////////////////////////////////////}
function TPluginVariation.ResetVariable(const Name: string) : boolean;
var
dummy: double;
@ -281,7 +281,7 @@ begin
end;
end;
///////////////////////////////////////////////////////////////////////////////
{////////////////////////////////////////////////////////////////////////////}
procedure InitializePlugins;
var
searchResult: TSearchRec;
@ -334,8 +334,7 @@ begin
@PluginVarResetVariable := GetProcAddress(PluginHandle,'PluginVarResetVariable');
RegisterVariation(TVariationPluginLoader.Create(PluginData), @PluginVarInit3D <> nil, @PluginVarInitDC <> nil);
//RegisterVariationFile(ExtractFilePath(Application.ExeName) + 'Plugins\' + searchResult.Name, name);
RegisterVariationFile(PluginPath + searchResult.Name, name); // AV: fixed!
//RegisterVariationFile(PluginPath + searchResult.Name, name); // AV: fixed!
end;
end else begin
errno := GetLastError;
@ -346,14 +345,20 @@ begin
until (FindNext(searchResult) <> 0);
SysUtils.FindClose(searchResult); //Since we use Windows unit (LoadLibrary)
// AV: now we can build the list of variation names
FillVarNamesList;
// AV: replaced Application.MessageBox by a more faster one from Windows unit
if msg <> '' then
Application.MessageBox(
MessageBox(0,
PChar('There were problems with some of the plugins:' + #13#10#13#10 + msg),
'Warning', MB_ICONWARNING or MB_OK); // TextByKey('common-loaderror1')
'Apophysis AV Warning', MB_ICONWARNING or MB_OK); // TextByKey('common-loaderror1')
end;
end;
///////////////////////////////////////////////////////////////////////////////
{ ////////////////////////////////////////////////////////////////////////// }
initialization
InitializePlugins;
end.

View File

@ -9,14 +9,22 @@ uses
type
TVariationHeart = class(TBaseVariation)
private
use3D: byte;
procedure Calc3D;
public
constructor Create;
class function GetName: string; override;
class function GetInstance: TBaseVariation; override;
function GetNrVariables: integer; override;
function GetVariableNameAt(const Index: integer): string; override;
function SetVariable(const Name: string; var value: double): boolean; override;
function GetVariable(const Name: string; var value: double): boolean; override;
procedure CalcFunction; override;
procedure GetCalcFunction(var f: TCalcFunction); override;
end;
@ -26,6 +34,12 @@ uses
Math;
////////////////////////
procedure TVariationHeart.GetCalcFunction(var f: TCalcFunction);
begin
if use3D <> 0 then
f := Calc3D
else f := CalcFunction;
end;
procedure TVariationHeart.CalcFunction;
var
@ -39,9 +53,26 @@ begin
FPy^ := FPy^ - r * cosr;
end;
procedure TVariationHeart.Calc3D;
var
FAngle, r, sinr, cosr: double;
begin
FAngle := arctan2(FTx^, FTy^);
r := sqrt(sqr(FTx^) + sqr(FTy^));
Sincos(r * FAngle, sinr, cosr);
r := r * vvar;
FPx^ := FPx^ + r * sinr;
FPy^ := FPy^ - r * cosr;
FAngle := arctan2(FTz^, FTy^);
r := sqrt(sqr(FTx^) + sqr(FTz^));
cosr := cos(r * FAngle);
FPz^ := FPz^ - vvar * r * cosr;
end;
constructor TVariationHeart.Create;
begin
inherited Create;
use3D := 0;
end;
class function TVariationHeart.GetInstance: TBaseVariation;
@ -54,8 +85,43 @@ begin
Result := 'heart';
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationHeart.GetVariableNameAt(const Index: integer): string;
begin
case Index of
0: Result := 'heart_use3D';
else
Result := '';
end;
end;
function TVariationHeart.GetNrVariables: integer;
begin
Result := 1;
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationHeart.SetVariable(const Name: string; var value: double): boolean;
begin
Result := False;
if Name = 'heart_use3D' then begin
if (Value > 1) then Value := 1;
if (Value < 0) then Value := 0;
use3D := Round(Value);
Result := True;
end;
end;
function TVariationHeart.GetVariable(const Name: string; var value: double): boolean;
begin
Result := False;
if Name = 'heart_use3D' then begin
Value := use3D;
Result := True;
end;
end;
//////////////////////////////
initialization
RegisterVariation(TVariationClassLoader.Create(TVariationHeart), false, false);
RegisterVariation(TVariationClassLoader.Create(TVariationHeart), true, false);
end.

View File

@ -4,14 +4,12 @@ unit varJulia;
interface
uses
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
AsmRandom,
{$endif}
BaseVariation, XFormMan;
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -26,8 +26,7 @@ unit varJulia3Djf; // original variation code by Joel Faber, modified & optimize
interface
uses
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
AsmRandom,
{$endif}
BaseVariation, XFormMan;
@ -36,8 +35,7 @@ const
var_name = 'julia3D';
var_n_name='julia3D_power';
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -26,8 +26,7 @@ unit varJulia3Dz;
interface
uses
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
AsmRandom,
{$endif}
BaseVariation, XFormMan;
@ -36,8 +35,7 @@ const
var_name = 'julia3Dz';
var_n_name='julia3Dz_power';
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -3,8 +3,7 @@ unit varJuliaN;
interface
uses
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
AsmRandom,
{$endif}
BaseVariation, XFormMan;
@ -14,8 +13,7 @@ const
var_n_name='julian_power';
var_c_name='julian_dist';
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -26,8 +26,7 @@ unit varJuliaScope;
interface
uses
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
AsmRandom,
{$endif}
BaseVariation, XFormMan;
@ -37,8 +36,7 @@ const
var_n_name='juliascope_power';
var_c_name='juliascope_dist';
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -60,7 +60,7 @@ uses
procedure TVariationNGon.Prepare;
begin
cpower := -0.5 * ngon_power;
csides := 2.0 * PI / ngon_sides;
csides := PI2 / ngon_sides; // AV: replaced 2.0 * PI by the const
csidesinv := 1.0 / csides;
end;
@ -68,9 +68,11 @@ procedure TVariationNGon.CalcFunction;
var
r_factor, theta, phi, amp: double;
begin
if (FTX^ = 0) and (FTY^ = 0) then r_factor := 0
else r_factor := Power(FTx^ * FTx^ + FTy^ * FTy^, cpower);
// AV: this check for a single case just slow down overall calculations
// since these 2 conditions are evaluated in every point
{ if (FTX^ = 0) and (FTY^ = 0) then
else } // <-- this will be true anyway
r_factor := Power(FTx^ * FTx^ + FTy^ * FTy^, cpower);
theta := ArcTan2(FTy^, FTx^);
@ -78,11 +80,12 @@ begin
if (phi > 0.5 * csides) then
phi := phi - csides;
// AV: and yeah, if (r_factor = 0) then also (amp = 0) so we must not calc it
amp := (ngon_corners * (1.0 / cos(phi) - 1.0) + ngon_circle) * VVAR * r_factor;
FPx^ := FPx^ + amp * FTx^;
FPy^ := FPy^ + amp * FTy^;
FPz^ := FPz^ + VVAR * FTz^;
FPz^ := FPz^ + VVAR * FTz^; // <-- AV: I don't like this since we have pre_zscale
end;
///////////////////////////////////////////////////////////////////////////////

View File

@ -29,8 +29,7 @@ interface
uses
BaseVariation, XFormMan;
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -46,11 +46,11 @@ begin
else
sn := 0;
FPx^ := FPx^ + vvar * (FTx^ + p2x * sn);
SinCos(p2c * FTx^, sn, cn);
SinCos(p2c * FTx^, sn, cn);
if cn <> 0 then // AV: safety tangent
sn := sin(sn / cn)
sn := sin(sn / cn)
else
sn := 0;
sn := 0;
FPy^ := FPy^ + vvar * (FTy^ + p2y * sn);
end;

View File

@ -87,6 +87,7 @@ begin
else if blurtype = 2 then f := CalcFunctionGaussian
else f := CalcFunction;
end;
procedure TVariationPostFalloff2.CalcFunction;
var
in_x, in_y, in_z, d: double;
@ -104,6 +105,7 @@ begin
FPz^ := VVAR * (in_z + mul_z * random * d);
color^ := Abs(Frac(color^ + mul_c * random * d));
end;
procedure TVariationPostFalloff2.CalcFunctionRadial;
var
in_x, in_y, in_z, d, r_in: double;
@ -130,6 +132,7 @@ begin
FPz^ := VVAR * (sins);
color^ := Abs(Frac(color^ + mul_c * random * d));
end;
procedure TVariationPostFalloff2.CalcFunctionGaussian;
var
in_x, in_y, in_z, d: double;

View File

@ -0,0 +1,254 @@
{
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
Apophysis "3D hack" Copyright (C) 2007-2008 Peter Sdobnov
Apophysis "7X" Copyright (C) 2009-2010 Georg Kiehne
Apophysis AV "Phoenix Edition" Copyright (C) 2021-2022 Alice V. Koryagina
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 varPostMobius;
interface
uses
BaseVariation, XFormMan;
type
TVariationPostMobius = class(TBaseVariation)
private
Re_A, Im_A, Re_B, Im_B, Re_C, Im_C, Re_D, Im_D: double;
mobius_invert : byte;
procedure CalcInvert;
public
constructor Create;
class function GetName: string; override;
class function GetInstance: TBaseVariation; override;
function GetNrVariables: integer; override;
function GetVariableNameAt(const Index: integer): string; override;
function SetVariable(const Name: string; var value: double): boolean; override;
function GetVariable(const Name: string; var value: double): boolean; override;
function ResetVariable(const Name: string): boolean; override;
procedure CalcFunction; override;
procedure GetCalcFunction(var f: TCalcFunction); override;
end;
implementation
uses
Math;
///////////////////////////////////////////////////////////////////////////////
procedure TVariationPostMobius.GetCalcFunction(var f: TCalcFunction);
begin // AV: this helps to increase the calc speed
if (mobius_invert <> 0) then
f := CalcInvert
else f := CalcFunction;
end;
procedure TVariationPostMobius.CalcFunction;
const EPS = 1E-100;
var
uRe, uIm, vRe, vIm, vDenom : double;
begin
uRe := (Re_A) * FPX^ - (Im_A) * FPY^ + (Re_B);
uIm := (Re_A) * FPY^ + (Im_A) * FPX^ + (Im_B);
vRe := (Re_C) * FPX^ - (Im_C) * FPY^ + (Re_D);
vIm := (Re_C) * FPY^ + (Im_C) * FPX^ + (Im_D);
vDenom := vRe * vRe + vIm * vIm;
if abs(vDenom) < EPS then vDenom := EPS;
FPx^ := VVAR * (uRe*vRe + uIm*vIm) / vDenom;
FPy^ := VVAR * (uIm*vRe - uRe*vIm) / vDenom;
end;
procedure TVariationPostMobius.CalcInvert; // inverse Mobius transformation
const EPS = 1E-100;
var
uRe, uIm, vRe, vIm, vDenom : double;
begin
uRe := (Re_D) * FPX^ - (Im_D) * FPY^ - (Re_B);
uIm := (Re_D) * FPY^ + (Im_D) * FPX^ - (Im_B);
vRe := -(Re_C) * FPX^ + (Im_C) * FPY^ + (Re_A);
vIm := -(Re_C) * FPY^ - (Im_C) * FPX^ + (Im_A);
vDenom := vRe * vRe + vIm * vIm;
if abs(vDenom) < EPS then vDenom := EPS;
FPx^ := VVAR * (uRe*vRe + uIm*vIm) / vDenom;
FPy^ := VVAR * (uIm*vRe - uRe*vIm) / vDenom;
end;
///////////////////////////////////////////////////////////////////////////////
constructor TVariationPostMobius.Create;
begin
Re_A := 1; Im_A := 0;
Re_B := 0; Im_B := 0;
Re_C := 0; Im_C := 0;
Re_D := 1; Im_D := 0;
mobius_invert := 0;
end;
///////////////////////////////////////////////////////////////////////////////
class function TVariationPostMobius.GetInstance: TBaseVariation;
begin
Result := TVariationPostMobius.Create;
end;
///////////////////////////////////////////////////////////////////////////////
class function TVariationPostMobius.GetName: string;
begin
Result := 'post_mobius';
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPostMobius.GetVariableNameAt(const Index: integer): string;
begin
case Index of
0: Result := 'post_mobius_Re_A';
1: Result := 'post_mobius_Im_A';
2: Result := 'post_mobius_Re_B';
3: Result := 'post_mobius_Im_B';
4: Result := 'post_mobius_Re_C';
5: Result := 'post_mobius_Im_C';
6: Result := 'post_mobius_Re_D';
7: Result := 'post_mobius_Im_D';
8: Result := 'post_mobius_invert';
else
Result := '';
end
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPostMobius.SetVariable(const Name: string; var value: double): boolean;
begin
Result := False;
if Name = 'post_mobius_Re_A' then begin
Re_A := Value;
Result := True;
end else if Name = 'post_mobius_Im_A' then begin
Im_A := Value;
Result := True;
end else if Name = 'post_mobius_Re_B' then begin
Re_B := Value;
Result := True;
end else if Name = 'post_mobius_Im_B' then begin
Im_B := Value;
Result := True;
end else if Name = 'post_mobius_Re_C' then begin
Re_C := Value;
Result := True;
end else if Name = 'post_mobius_Im_C' then begin
Im_C := Value;
Result := True;
end else if Name = 'post_mobius_Re_D' then begin
Re_D := Value;
Result := True;
end else if Name = 'post_mobius_Im_D' then begin
Im_D := Value;
Result := True;
end else if Name = 'post_mobius_invert' then begin
if (Value > 1) then Value := 1;
if (Value < 0) then Value := 0;
mobius_invert := Round(Value);
Result := True;
end
end;
function TVariationPostMobius.ResetVariable(const Name: string): boolean;
begin
Result := False;
if Name = 'post_mobius_Re_A' then begin
Re_A := 1;
Result := True;
end else if Name = 'post_mobius_Im_A' then begin
Im_A := 0;
Result := True;
end else if Name = 'post_mobius_Re_B' then begin
Re_B := 0;
Result := True;
end else if Name = 'post_mobius_Im_B' then begin
Im_B := 0;
Result := True;
end else if Name = 'post_mobius_Re_C' then begin
Re_C := 0;
Result := True;
end else if Name = 'post_mobius_Im_C' then begin
Im_C := 0;
Result := True;
end else if Name = 'post_mobius_Re_D' then begin
Re_D := 1;
Result := True;
end else if Name = 'post_mobius_Im_D' then begin
Im_D := 0;
Result := True;
end else if Name = 'post_mobius_invert' then begin
mobius_invert := 0;
Result := True;
end
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPostMobius.GetNrVariables: integer;
begin
Result := 9
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPostMobius.GetVariable(const Name: string; var value: double): boolean;
begin
Result := False;
if Name = 'post_mobius_Re_A' then begin
Value := Re_A;
Result := True;
end else if Name = 'post_mobius_Im_A' then begin
Value := Im_A;
Result := True;
end else if Name = 'post_mobius_Re_B' then begin
Value := Re_B;
Result := True;
end else if Name = 'post_mobius_Im_B' then begin
Value := Im_B;
Result := True;
end else if Name = 'post_mobius_Re_C' then begin
Value := Re_C;
Result := True;
end else if Name = 'post_mobius_Im_C' then begin
Value := Im_C;
Result := True;
end else if Name = 'post_mobius_Re_D' then begin
Value := Re_D;
Result := True;
end else if Name = 'post_mobius_Im_D' then begin
Value := Im_D;
Result := True;
end else if Name = 'post_mobius_invert' then begin
Value := mobius_invert;
Result := True;
end
end;
///////////////////////////////////////////////////////////////////////////////
initialization
RegisterVariation(TVariationClassLoader.Create(TVariationPostMobius), false, false);
end.

View File

@ -7,8 +7,7 @@ interface
uses
BaseVariation, XFormMan;
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -1,4 +1,4 @@
{ Apophysis AV "Phoenix Edition" Copyright (C) 2021 Alice V. Koryagina }
{ Apophysis AV "Phoenix Edition" Copyright (C) 2021-2022 Alice V. Koryagina }
unit varPower;
@ -9,14 +9,22 @@ uses
type
TVariationPower = class(TBaseVariation)
private
use3D: byte;
procedure Calc3D;
public
constructor Create;
class function GetName: string; override;
class function GetInstance: TBaseVariation; override;
function GetNrVariables: integer; override;
function GetVariableNameAt(const Index: integer): string; override;
function SetVariable(const Name: string; var value: double): boolean; override;
function GetVariable(const Name: string; var value: double): boolean; override;
procedure CalcFunction; override;
procedure GetCalcFunction(var f: TCalcFunction); override;
end;
@ -27,14 +35,35 @@ uses
////////////////////////
procedure TVariationPower.GetCalcFunction(var f: TCalcFunction);
begin
if use3D <> 0 then f := Calc3D // AV: added optional 3d-support
else f := CalcFunction;
end;
procedure TVariationPower.Calc3D; // AV
var
r, FSinA, FCosA: double;
begin
r := sqrt(sqr(FTx^) + sqr(FTy^) + sqr(FTz^)) + 1E-300;
FSinA := FTx^ / r;
FCosA := FTy^ / r;
r := vvar * Math.Power(r, FSinA);
FPx^ := FPx^ + r * FCosA;
FPy^ := FPy^ + r * FSinA;
// transform the plane into 3d-shape
r := vvar * Math.Power(r, FCosA);
FPz^ := FPz^ + r * FCosA; //FSinA;
end;
procedure TVariationPower.CalcFunction;
var
r, FLength, FSinA, FCosA: double;
r, FSinA, FCosA: double;
begin
FLength := sqrt(sqr(FTx^) + sqr(FTy^)) + 1E-300;
FSinA := FTx^ / FLength;
FCosA := FTy^ / FLength;
r := vvar * Math.Power(FLength, FSinA);
r := sqrt(sqr(FTx^) + sqr(FTy^)) + 1E-300;
FSinA := FTx^ / r;
FCosA := FTy^ / r;
r := vvar * Math.Power(r, FSinA);
FPx^ := FPx^ + r * FCosA;
FPy^ := FPy^ + r * FSinA;
end;
@ -42,6 +71,7 @@ end;
constructor TVariationPower.Create;
begin
inherited Create;
use3D := 0;
end;
class function TVariationPower.GetInstance: TBaseVariation;
@ -54,8 +84,44 @@ begin
Result := 'power';
end;
function TVariationPower.GetNrVariables: integer;
begin
Result := 1;
end;
function TVariationPower.GetVariableNameAt(const Index: integer): string;
begin
case Index of
0: Result := 'power_use3D';
else
Result := '';
end;
end;
function TVariationPower.GetVariable(const Name: string;
var value: double): boolean;
begin
Result := False;
if Name = 'power_use3D' then begin
Value := use3D;
Result := True;
end;
end;
function TVariationPower.SetVariable(const Name: string;
var value: double): boolean;
begin
Result := False;
if Name = 'power_use3D' then begin
if (Value > 1) then Value := 1;
if (Value < 0) then Value := 0;
use3D := Round(Value);
Result := True;
end;
end;
//////////////////////////////
initialization
RegisterVariation(TVariationClassLoader.Create(TVariationPower), false, false);
RegisterVariation(TVariationClassLoader.Create(TVariationPower), true, false);
end.

254
Variations/varPreMobius.pas Normal file
View File

@ -0,0 +1,254 @@
{
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
Apophysis "3D hack" Copyright (C) 2007-2008 Peter Sdobnov
Apophysis "7X" Copyright (C) 2009-2010 Georg Kiehne
Apophysis AV "Phoenix Edition" Copyright (C) 2021-2022 Alice V. Koryagina
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 varPreMobius;
interface
uses
BaseVariation, XFormMan;
type
TVariationPreMobius = class(TBaseVariation)
private
Re_A, Im_A, Re_B, Im_B, Re_C, Im_C, Re_D, Im_D: double;
mobius_invert : byte;
procedure CalcInvert;
public
constructor Create;
class function GetName: string; override;
class function GetInstance: TBaseVariation; override;
function GetNrVariables: integer; override;
function GetVariableNameAt(const Index: integer): string; override;
function SetVariable(const Name: string; var value: double): boolean; override;
function GetVariable(const Name: string; var value: double): boolean; override;
function ResetVariable(const Name: string): boolean; override;
procedure CalcFunction; override;
procedure GetCalcFunction(var f: TCalcFunction); override;
end;
implementation
uses
Math;
///////////////////////////////////////////////////////////////////////////////
procedure TVariationPreMobius.GetCalcFunction(var f: TCalcFunction);
begin // AV: this helps to increase the calc speed
if (mobius_invert <> 0) then
f := CalcInvert
else f := CalcFunction;
end;
procedure TVariationPreMobius.CalcFunction;
const EPS = 1E-100;
var
uRe, uIm, vRe, vIm, vDenom : double;
begin
uRe := (Re_A) * FTx^ - (Im_A) * FTy^ + (Re_B);
uIm := (Re_A) * FTy^ + (Im_A) * FTx^ + (Im_B);
vRe := (Re_C) * FTx^ - (Im_C) * FTy^ + (Re_D);
vIm := (Re_C) * FTy^ + (Im_C) * FTx^ + (Im_D);
vDenom := vRe * vRe + vIm * vIm;
if abs(vDenom) < EPS then vDenom := EPS;
FTx^ := VVAR * (uRe*vRe + uIm*vIm) / vDenom;
FTy^ := VVAR * (uIm*vRe - uRe*vIm) / vDenom;
end;
procedure TVariationPreMobius.CalcInvert; // inverse Mobius transformation
const EPS = 1E-100;
var
uRe, uIm, vRe, vIm, vDenom : double;
begin
uRe := (Re_D) * FTX^ - (Im_D) * FTY^ - (Re_B);
uIm := (Re_D) * FTY^ + (Im_D) * FTx^ - (Im_B);
vRe := -(Re_C) * FTx^ + (Im_C) * FTy^ + (Re_A);
vIm := -(Re_C) * FTy^ - (Im_C) * FTx^ + (Im_A);
vDenom := vRe * vRe + vIm * vIm;
if abs(vDenom) < EPS then vDenom := EPS;
FTx^ := VVAR * (uRe*vRe + uIm*vIm) / vDenom;
FTy^ := VVAR * (uIm*vRe - uRe*vIm) / vDenom;
end;
///////////////////////////////////////////////////////////////////////////////
constructor TVariationPreMobius.Create;
begin
Re_A := 1; Im_A := 0;
Re_B := 0; Im_B := 0;
Re_C := 0; Im_C := 0;
Re_D := 1; Im_D := 0;
mobius_invert := 0;
end;
///////////////////////////////////////////////////////////////////////////////
class function TVariationPreMobius.GetInstance: TBaseVariation;
begin
Result := TVariationPreMobius.Create;
end;
///////////////////////////////////////////////////////////////////////////////
class function TVariationPreMobius.GetName: string;
begin
Result := 'pre_mobius';
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPreMobius.GetVariableNameAt(const Index: integer): string;
begin
case Index of
0: Result := 'pre_mobius_Re_A';
1: Result := 'pre_mobius_Im_A';
2: Result := 'pre_mobius_Re_B';
3: Result := 'pre_mobius_Im_B';
4: Result := 'pre_mobius_Re_C';
5: Result := 'pre_mobius_Im_C';
6: Result := 'pre_mobius_Re_D';
7: Result := 'pre_mobius_Im_D';
8: Result := 'pre_mobius_invert';
else
Result := '';
end
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPreMobius.SetVariable(const Name: string; var value: double): boolean;
begin
Result := False;
if Name = 'pre_mobius_Re_A' then begin
Re_A := Value;
Result := True;
end else if Name = 'pre_mobius_Im_A' then begin
Im_A := Value;
Result := True;
end else if Name = 'pre_mobius_Re_B' then begin
Re_B := Value;
Result := True;
end else if Name = 'pre_mobius_Im_B' then begin
Im_B := Value;
Result := True;
end else if Name = 'pre_mobius_Re_C' then begin
Re_C := Value;
Result := True;
end else if Name = 'pre_mobius_Im_C' then begin
Im_C := Value;
Result := True;
end else if Name = 'pre_mobius_Re_D' then begin
Re_D := Value;
Result := True;
end else if Name = 'pre_mobius_Im_D' then begin
Im_D := Value;
Result := True;
end else if Name = 'pre_mobius_invert' then begin
if (Value > 1) then Value := 1;
if (Value < 0) then Value := 0;
mobius_invert := Round(Value);
Result := True;
end
end;
function TVariationPreMobius.ResetVariable(const Name: string): boolean;
begin
Result := False;
if Name = 'pre_mobius_Re_A' then begin
Re_A := 1;
Result := True;
end else if Name = 'pre_mobius_Im_A' then begin
Im_A := 0;
Result := True;
end else if Name = 'pre_mobius_Re_B' then begin
Re_B := 0;
Result := True;
end else if Name = 'pre_mobius_Im_B' then begin
Im_B := 0;
Result := True;
end else if Name = 'pre_mobius_Re_C' then begin
Re_C := 0;
Result := True;
end else if Name = 'pre_mobius_Im_C' then begin
Im_C := 0;
Result := True;
end else if Name = 'pre_mobius_Re_D' then begin
Re_D := 1;
Result := True;
end else if Name = 'pre_mobius_Im_D' then begin
Im_D := 0;
Result := True;
end else if Name = 'pre_mobius_invert' then begin
mobius_invert := 0;
Result := True;
end
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPreMobius.GetNrVariables: integer;
begin
Result := 9
end;
///////////////////////////////////////////////////////////////////////////////
function TVariationPreMobius.GetVariable(const Name: string; var value: double): boolean;
begin
Result := False;
if Name = 'pre_mobius_Re_A' then begin
Value := Re_A;
Result := True;
end else if Name = 'pre_mobius_Im_A' then begin
Value := Im_A;
Result := True;
end else if Name = 'pre_mobius_Re_B' then begin
Value := Re_B;
Result := True;
end else if Name = 'pre_mobius_Im_B' then begin
Value := Im_B;
Result := True;
end else if Name = 'pre_mobius_Re_C' then begin
Value := Re_C;
Result := True;
end else if Name = 'pre_mobius_Im_C' then begin
Value := Im_C;
Result := True;
end else if Name = 'pre_mobius_Re_D' then begin
Value := Re_D;
Result := True;
end else if Name = 'pre_mobius_Im_D' then begin
Value := Im_D;
Result := True;
end else if Name = 'pre_mobius_invert' then begin
Value := mobius_invert;
Result := True;
end
end;
///////////////////////////////////////////////////////////////////////////////
initialization
RegisterVariation(TVariationClassLoader.Create(TVariationPreMobius), false, false);
end.

View File

@ -29,8 +29,7 @@ interface
uses
BaseVariation, XFormMan;
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -28,8 +28,7 @@ interface
uses
BaseVariation, XFormMan;
{$ifdef Apo7X64}
{$else}
{$ifdef CPUX86}
{$define _ASM_}
{$endif}

View File

@ -40,7 +40,7 @@ procedure TVariationTanhSpiral.CalcFunction;
var
t, aux, sn, cn, snh, cnh: double;
begin
t := (random - 0.5) * 6.28318530717959;
t := (random - 0.5) * PI2;
SinCos(ta * t, sn, cn);
SinhCosh(t, snh, cnh);