POV-Ray : Newsgroups : povray.advanced-users : Array initializer versus macros - syntax error : Re: Array initializer versus macros - syntax error Server Time
26 Jun 2024 09:11:25 EDT (-0400)
  Re: Array initializer versus macros - syntax error  
From: Drakonis
Date: 3 Mar 2012 09:15:00
Message: <web.4f52273ac0fcd54d2693ad740@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
>   Did you try what Thorsten suggested, ie. declaring a local identifier
> and "returning" it from the macro? In other words, like:
>
> #macro ColorMapMacro(lineColor)
>   #local ColorMap =
>     color_map
>     {
>       [ 0.0 color rgb 0 ]
>       [ 0.5 color rgb lineColor  ]
>       [ 1.0 color rgb 0  ]
>     };
>   ColorMap
> #end
>
>   (Haven't tested it myself to see if it works...)

Sorry about the delay, real life keeps interrupting my render sessions!  Yes, I
tried it and it did NOT fix the problem.

However, I have found a slightly less-pretty workaround, so I will be using that
for now.  That is as I mentioned above, for some reason if I use explicit
initialization of each array element, it works.  It is just the
auto-initialization that fails... but that means I'll have to write it this way:

// define a Macro that creates a color_map
#macro ColorMapMacro(lineColor)
color_map
{
 [ 0.0 color rgb 0 ]
 [ 0.5 color rgb lineColor  ]
 [ 1.0 color rgb 0  ]
}
#end

// declare an array of color_maps
#local ColorMapArray1 = array[3];

// now MANUALLY initialize each element

maintain :-)
#local ColorMapArray1[0] =  ColorMapMacro(<1,1,0>);
#local ColorMapArray1[1] =  ColorMapMacro(<1,0,1>);
#local ColorMapArray1[2] =  ColorMapMacro(<0,1,1>);

But, this gets me back on my way.  Thank you both for your clarifying help.
ttfn,
Eduard


Post a reply to this message

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