POV-Ray : Newsgroups : povray.general : how to call multiple instances of a macro? : Re: how to call multiple instances of a macro? Server Time
30 Jul 2024 12:31:06 EDT (-0400)
  Re: how to call multiple instances of a macro?  
From: Christian Froeschlin
Date: 15 Feb 2009 13:40:27
Message: <4998619b$1@news.povray.org>
Christian Froeschlin wrote:

> [GDS|Entropy] wrote:
> 
>> Would one be able to pass signs (+ - / *)
> 
> no

Of course, no one prevents you from passing a function
which performs the operation, whatever your reasons:

   #declare op_add  = function(x,y){x+y}
   #declare op_sub  = function(x,y){x-y}
   #declare op_mult = function(x,y){x*y}
   #declare op_div  = function(x,y){x/y}
   #declare op_avg  = function(x,y){0.5*op_add(x,y)}

   #macro ConcatFunc(OP,F1,F2)
     function {OP(F1(x,y,z),F2(x,y,z))}
   #end

   #declare f_combined = ConcatFunc(op_avg, f_bozo, f_agate)

Just think clearly about what you wish to achieve before doing it ;)


Post a reply to this message

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