|
![](/i/fill.gif) |
Hi everybody!
It has been quite a long time since I last posted here - or used POV
for that matter. Probably a year. For my defence I must say I had no
occasion to do so - no time, no computer and/or no phone line (hence no
Internet access). I now have my computer back, some more time and a
good connection at work (ISDN).
I have been browsing news.povray silently for two weeks. It is really
good to read all of you again.
SO
As I am back to using POV, I am back to having problems with it. Can
anybody tell me what's wrong here?
I got a problem with colour component extraction. It seems that when
you use colour component extraction and use the result immediately,
what you got is a float. But if there is an intermediate step
(#declare, #local or pass as a macro argument), it reverts to a colour.
In other word:
floatFunction(aColor.red) is OK, but
#declare myFloat=aColor.red is not a float but a colour
I suspect this is a bug. But of course I could be wrong (would not be
the first time). Could you please check? I browsed p.bugreports but
could find nothing related.
Here is an illustration of the problem, along with some tests to narrow
it:
(All the lines that cause an error before 'no object in scene' are
commented.) (All 'should work' or 'should fail' are based on what I
expect POV to do.)
*/
#declare LightBrown=color rgb <1,.5,.3>; // declare a color
#declare BlueComponent=LightBrown.blue; // extract blue component
// this should be a float
/* Quote from doc :
You may use the dot operator to extract a single component from a
color. Suppose the identifier Shade was previously defined as a color.
Then Shade.red is the float value of the red component of Shade.
Similarly Shade.green, Shade.blue, Shade.filter and Shade.transmit
extract the float value of the other color components.
*/
// The simplest illustration
#declare Test1=abs(LightBrown.blue); // this works
// #declare Test2=abs(BlueComponent); // this fails
// With macros:
// Direct return without assignment
#macro Test3Macro(cColor)
cColor.blue
#end
#declare Test3=abs(Test3Macro(LightBrown)); // this works
/*
// Return with #local
#macro Test4Macro(cColor)
#local Test4Return=cColor.blue;
Test4Return
#end
#declare Test4=abs(Test4Macro(LightBrown)); // this fails
*/
/*
// Color component as an argument
#macro Test5Macro(fFloat)
abs(fFloat);
#end
#declare Test5=Test5Macro(LightBrown.blue); // this fails
*/
// Q: What type is BlueComponent?
// A: color!
// #declare BlueComponent=LightBrown; // this works and should not
// #declare BlueComponent=pi; // this fails but should work
#declare BlueBlueComponent=BlueComponent.blue; // this works OK
// #declare BlueBlueComponent=pi; // this fails but should work
// Q: If BlueComponent is a color, is it rgbft<0,0,blue,0,0>?
// A: It seems BlueComponent = color blue, giving
// rgbft <blue,blue,blue,blue,blue> with operator promotion.
// read the #debug stream
#debug "\n\n BlueComponent=rgbft < "
#debug str(BlueComponent.red,2,2)
#debug ", "
#debug str(BlueComponent.green,2,2)
#debug ", "
#debug str(BlueComponent.blue,2,2)
#debug ", "
#debug str(BlueComponent.filter,2,2)
#debug ", "
#debug str(BlueComponent.transmit,2,2)
#debug " >\n\n"
// Q: What about the other components?
// A: Same problem.
#declare RedComponent=LightBrown.red;
// #declare Test9=abs(RedComponent); // this fails but should work
#declare GreenComponent=LightBrown.green;
// #declare Test10=abs(GreenComponent); // this fails but should work
#declare FilterComponent=LightBrown.filter;
// #declare Test11=abs(FilterComponent); // this fails but should work
#declare TransmitComponent=LightBrown.transmit;
// #declare Test12=abs(TransmitComponent); // this fails but should work
// Testing myself for sanity
// #declare test13=pi.blue; // this fails OK - as it should
// #declare test14=abs(LightBrown); // this fails OK
#declare test15=<1,2,3>.x;
#declare test15=pi; // this works OK
#declare test16=<1,2,3>.red;
#declare test16=pi; // this works OK
#declare test17=rgb <1,2,3>;
#declare test17=test17.blue; // this works and should not
// #declare test17=pi; // this fails OK
#declare test18=color rgb <1,2,3>;
#declare test18=test18.blue; // this works and should not
#declare test18=test18.x; // this works and should not
// #declare test18=pi; // this fails OK
// #declare test19=color <1>; // this fails OK
#declare test20=color 1; // this works
#declare test21=abs(LightBrown.blue);// this works OK
#declare test21=pi; // this works OK
Post a reply to this message
|
![](/i/fill.gif) |