|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi, I have the following macro (simplified for brevity).
#macro ColorFromBurgers(burgers)
/* good 11-color map from http://colorbrewer2.org
#warning concat("Got burgers value: ",str(burgers,0,0),"\n")
*/
#switch(burgers)
#range (-5,-1)
rgb <141,211,199>/255.0
#break
#case (0)
rgb <255,255,179>/255.0
#break
#case (10)
rgb <190,186,218>/255.0
#break
#end
#end
I want to print out the color my macro is returning somehow.
I've tried the following with no success:
First I tried:
#warning concat("The color is ",ColorFromBurgers(burger),"\n")
but I get an error about not having three arguments.
File Context (5 lines):
rgb <251,128,114>/255.0
#break
#case (12)
rgb <128,177,211>/255.0
#
Parse Error: Expected 3 parameters but only 1 found.
Strange that none of the lines seems to be anything that needs 3 parameters.
Tried a couple other things, but nothing seems to work.
The last thing i just tried before giving up was this:
#declare c = color ColorFromBurgers(burger);
#declare s = CRGBStr(color c ,0,0);
#warning concat("The color is ",s,"\n")
I get
#declare c = color ColorFromBurgers
Parse Error: All #declares of float, vector, and color require semi-colon ';' at
end if the language version is set to 3.5 or higher. Either add the semi-colon
or set the language version to 3.1 or lower.
Help! Thanks
Post a reply to this message
|
|
| |
| |
|
|
From: clipka
Subject: Re: How to print a color generated by a macro?
Date: 25 Aug 2014 23:41:41
Message: <53fc01f5@news.povray.org>
|
|
|
| |
| |
|
|
Am 26.08.2014 04:30, schrieb wealthychef:
> Hi, I have the following macro (simplified for brevity).
>
> #macro ColorFromBurgers(burgers)
> /* good 11-color map from http://colorbrewer2.org
> #warning concat("Got burgers value: ",str(burgers,0,0),"\n")
> */
> #switch(burgers)
> #range (-5,-1)
> rgb <141,211,199>/255.0
> #break
> #case (0)
> rgb <255,255,179>/255.0
> #break
> #case (10)
> rgb <190,186,218>/255.0
> #break
> #end
> #end
>
> I want to print out the color my macro is returning somehow.
> I've tried the following with no success:
> First I tried:
> #warning concat("The color is ",ColorFromBurgers(burger),"\n")
> but I get an error about not having three arguments.
> File Context (5 lines):
> rgb <251,128,114>/255.0
> #break
> #case (12)
> rgb <128,177,211>/255.0
> #
> Parse Error: Expected 3 parameters but only 1 found.
>
> Strange that none of the lines seems to be anything that needs 3 parameters.
"Returning" values from within control structures in a macro can be
troublesome; try something like this:
#macro ColorFromBurgers(burgers)
#switch(burgers)
#range(-5,-1)
#local Result = rgb <141,211,199>/255.0;
#break
#case (0)
#local Result = rgb <255,255,179>/255.0;
#break
#case (10)
#local Result = rgb <190,186,218>/255.0;
#break
#end
Result
#end
As for printing the result, remember that colours are vector-like
beasts, so vstr() should do the job.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
clipka <ano### [at] anonymousorg> wrote:
> Am 26.08.2014 04:30, schrieb wealthychef:
> > I want to print out the color my macro is returning somehow.
> > I've tried blah blah blah... FAIL
>
> "Returning" values from within control structures in a macro can be
> troublesome; try something like this:
>
> #macro ColorFromBurgers(burgers)
> #switch(burgers)
> #range(-5,-1)
> #local Result = rgb <141,211,199>/255.0;
> #break
> #case (0)
> #local Result = rgb <255,255,179>/255.0;
> #break
> #case (10)
> #local Result = rgb <190,186,218>/255.0;
> #break
> #end
> Result
> #end
>
>
> As for printing the result, remember that colours are vector-like
> beasts, so vstr() should do the job.
Thank you so much for the help! Cheers. That worked great.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|