{ Apophysis AV "Phoenix Edition" Copyright (C) 2021 Alice V. Koryagina "Chaotica" Copyright (C) 2019 Glare Technologies Limited } unit varCothSpiral; interface uses BaseVariation, XFormMan; type TVariationCothSpiral = 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 TVariationCothSpiral.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 TVariationCothSpiral.Create; begin inherited Create; ta := 4; end; class function TVariationCothSpiral.GetInstance: TBaseVariation; begin Result := TVariationCothSpiral.Create; end; class function TVariationCothSpiral.GetName: string; begin Result := 'coth_spiral'; end; function TVariationCothSpiral.GetNrVariables: integer; begin Result := 1; end; function TVariationCothSpiral.GetVariableNameAt(const Index: integer): string; begin case Index Of 0: Result := 'coth_spiral_a'; else Result := ''; end; end; function TVariationCothSpiral.GetVariable(const Name: string; var value: double): boolean; begin Result := False; if Name = 'coth_spiral_a' then begin Value := ta; Result := True; end; end; function TVariationCothSpiral.SetVariable(const Name: string; var value: double): boolean; begin Result := False; if Name = 'coth_spiral_a' then begin ta := Value; Result := True; end; end; function TVariationCothSpiral.ResetVariable(const Name: string): boolean; begin Result := False; if Name = 'coth_spiral_a' then begin ta := 4; Result := True; end; end; ////////////////////////////// initialization RegisterVariation(TVariationClassLoader.Create(TVariationCothSpiral), false, false); end.