POV-Ray : Newsgroups : povray.advanced-users : Color component extraction: Bug or advanced feature? Server Time
25 Dec 2024 01:32:38 EST (-0500)
  Color component extraction: Bug or advanced feature? (Message 1 to 3 of 3)  
From: Simen Kvaal
Subject: Color component extraction: Bug or advanced feature?
Date: 7 May 2000 17:40:35
Message: <3915e2d3$1@news.povray.org>
Forgive me for being so active posting here lately. I guess it's me being
very active in raytracing these days... Anyway; I feel that this is the
right group to post in, so...

I've been writing color-space conversion macros, and needed to extract the
individual float values in the color vector. I looked up in the docs, and it
said that one should extract with e.g. Color.red to get the red component
float. But this does not work as stated in the manual; instead it generates
(I found out after a lot of hassle) a 5-color vector with _all_ the
components set as that Color.red-value. Is this really how it's supposed to
be? I cannot see _any_ way of extracting a color component from a #declared
color; one cannot even do things like vlength() and vdot() on them, and
that's frustrating. I got around using something like
val(str(Color.red),10,10), but I cannot really see why that should be
working. Placing Color.red in a statement like:

#declare MyGoodFriend = <Color.red, Color.green, Color.blue>

to make a space-vector generates an error, stating that Color.red is a color
vector, and that a float value was expected!

Comparing with the method for extracting x, y and z components from a normal
3-vector, the color component extraction method doesn't at all work as
expected.

To sum it up: Does the float-extraction feature contain a serious bug? Or
are the docs simply poorly written here and/or too brief?

regards,
Simen. (who hates to use val(str()) to accomplish extraction of color
components....)


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Color component extraction: Bug or advanced feature?
Date: 7 May 2000 18:15:32
Message: <3915eb04@news.povray.org>
In article <3915e2d3$1@news.povray.org> , "Simen Kvaal" 
<sim### [at] studentmatnatuiono> wrote:

> #declare MyGoodFriend = <Color.red, Color.green, Color.blue>

Use

#declare MyGoodFriend = <(Color.red), (Color.green), (Color.blue)>;

instead.

The current parser is not perfect, and with complicated expressions
involving dot access to components of vectors and colors it sometimes acts
strange. We are aware of the various problems, especially when using dot
operations for color vectors, but this may not be fixed before the parser is
rewritten (i.e. in POV-Ray 4.0).

For now, usually placing braces around such operations works around most
problems (due the the recursive decent parsing used).


       Thorsten


____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Simen Kvaal
Subject: Re: Color component extraction: Bug or advanced feature?
Date: 7 May 2000 18:24:36
Message: <3915ed24$1@news.povray.org>
Thanks a lot! I should have thought of that, but I just _had_ to make a big
problem out of it... :-( Now all my macros become _much_ nicer written,
thanks to you!

Simen.

>Use
>#declare MyGoodFriend = <(Color.red), (Color.green), (Color.blue)>;
>instead.


Post a reply to this message

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