POV-Ray : Newsgroups : povray.general : declare a variable in a function : Re: declare a variable in a function Server Time
23 Jun 2021 01:09:20 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-2021 Persistence of Vision Raytracer Pty. Ltd.