2022-03-08 12:25:51 -05:00
|
|
|
{ Apophysis AV "Phoenix Edition" Copyright (C) 2021 Alice V. Koryagina }
|
|
|
|
|
|
|
|
unit varHeart;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
BaseVariation, XFormMan;
|
|
|
|
|
|
|
|
type
|
|
|
|
TVariationHeart = class(TBaseVariation)
|
|
|
|
private
|
2022-06-23 06:22:32 -04:00
|
|
|
use3D: byte;
|
|
|
|
procedure Calc3D;
|
2022-03-08 12:25:51 -05:00
|
|
|
public
|
|
|
|
constructor Create;
|
|
|
|
|
|
|
|
class function GetName: string; override;
|
|
|
|
class function GetInstance: TBaseVariation; override;
|
|
|
|
|
2022-06-23 06:22:32 -04:00
|
|
|
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;
|
|
|
|
|
2022-03-08 12:25:51 -05:00
|
|
|
procedure CalcFunction; override;
|
2022-06-23 06:22:32 -04:00
|
|
|
procedure GetCalcFunction(var f: TCalcFunction); override;
|
2022-03-08 12:25:51 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
Math;
|
|
|
|
|
|
|
|
////////////////////////
|
2022-06-23 06:22:32 -04:00
|
|
|
procedure TVariationHeart.GetCalcFunction(var f: TCalcFunction);
|
|
|
|
begin
|
|
|
|
if use3D <> 0 then
|
|
|
|
f := Calc3D
|
|
|
|
else f := CalcFunction;
|
|
|
|
end;
|
2022-03-08 12:25:51 -05:00
|
|
|
|
|
|
|
procedure TVariationHeart.CalcFunction;
|
|
|
|
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;
|
|
|
|
end;
|
|
|
|
|
2022-06-23 06:22:32 -04:00
|
|
|
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;
|
|
|
|
|
2022-03-08 12:25:51 -05:00
|
|
|
constructor TVariationHeart.Create;
|
|
|
|
begin
|
|
|
|
inherited Create;
|
2022-06-23 06:22:32 -04:00
|
|
|
use3D := 0;
|
2022-03-08 12:25:51 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TVariationHeart.GetInstance: TBaseVariation;
|
|
|
|
begin
|
|
|
|
Result := TVariationHeart.Create;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class function TVariationHeart.GetName: string;
|
|
|
|
begin
|
|
|
|
Result := 'heart';
|
|
|
|
end;
|
|
|
|
|
2022-06-23 06:22:32 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
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;
|
|
|
|
|
2022-03-08 12:25:51 -05:00
|
|
|
//////////////////////////////
|
|
|
|
initialization
|
2022-06-23 06:22:32 -04:00
|
|
|
RegisterVariation(TVariationClassLoader.Create(TVariationHeart), true, false);
|
2022-03-08 12:25:51 -05:00
|
|
|
|
|
|
|
end.
|