{ Apophysis AV "Phoenix Edition" Copyright (C) 2021 Alice V. Koryagina "Chaotica" Copyright (C) 2019 Glare Technologies Limited } unit varTanhSpiral; interface uses BaseVariation, XFormMan; type TVariationTanhSpiral = class(TBaseVariation) private ta: double; 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; end; implementation uses Math; //////////////////////// procedure TVariationTanhSpiral.CalcFunction; var t, aux, sn, cn, snh, cnh: double; begin t := (random - 0.5) * PI2; SinCos(ta * t, sn, cn); SinhCosh(t, snh, cnh); aux := (cn + cnh); if aux = 0 then aux := 1e-20; aux := vvar / aux; FPx^ := FPx^ + snh * aux; FPy^ := FPy^ + sn * aux; end; constructor TVariationTanhSpiral.Create; begin inherited Create; ta := 4; end; class function TVariationTanhSpiral.GetInstance: TBaseVariation; begin Result := TVariationTanhSpiral.Create; end; class function TVariationTanhSpiral.GetName: string; begin Result := 'tanh_spiral'; end; function TVariationTanhSpiral.GetNrVariables: integer; begin Result := 1; end; function TVariationTanhSpiral.GetVariableNameAt(const Index: integer): string; begin case Index Of 0: Result := 'tanh_spiral_a'; else Result := ''; end; end; function TVariationTanhSpiral.GetVariable(const Name: string; var value: double): boolean; begin Result := False; if Name = 'tanh_spiral_a' then begin Value := ta; Result := True; end; end; function TVariationTanhSpiral.SetVariable(const Name: string; var value: double): boolean; begin Result := False; if Name = 'tanh_spiral_a' then begin ta := Value; Result := True; end; end; function TVariationTanhSpiral.ResetVariable(const Name: string): boolean; begin Result := False; if Name = 'tanh_spiral_a' then begin ta := 4; Result := True; end; end; ////////////////////////////// initialization RegisterVariation(TVariationClassLoader.Create(TVariationTanhSpiral), false, false); end.