POV-Ray : Newsgroups : povray.general : declare a variable in a function : Re: declare a variable in a function Server Time
24 Apr 2024 11:07:10 EDT (-0400)
  Re: declare a variable in a function  
From: ingo
Date: 3 Apr 2021 02:47:21
Message: <XnsAD015969220ADseed7@news.povray.org>
in news:web.6067a28edb16780d6f19eb189db30a9@news.povray.org Tor Olav 
Kristensen wrote:

> I'm sorry, but I have no recollection of such a feature.

Maybe it was this "abuse" I was thinking of:


#declare Ramp = function(Freq, Tick, SRate){
  mod(Tick, SRate/Freq) * (Freq/SRate)
} 

#declare TriOsc = function(Freq, Amp, Tick, SRate) {
  #local TriSelect = function(R) {
    select(
      R - 0.25,
      R,
      select(
        R - 0.75,
        0.5 - R,
        R - 1
      )
    )
  };
  4*Amp*TriSelect(Ramp(Freq,Tick,SRate))
};

It adds nothing but keeping the functions together in one block,

Ingo


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.