POV-Ray : Newsgroups : povray.general : a macro : Re: a macro Server Time
2 Aug 2024 12:16:15 EDT (-0400)
  Re: a macro  
From: Mike Williams
Date: 31 Oct 2004 02:04:58
Message: <WGTtdBAI6IhBFw0P@econym.demon.co.uk>
Wasn't it Aeroslin who wrote:
>Hello everyone.
>
>I had a desire to pull color values from Paintshop Pro in order to use them
>in POV.  The native color format is RGB-255 which, according to the help,
>doesn't support 255 values, only 0 - 1 values.  In order to translate
>between the two formats I created my first macro and to my surprise, it
>works!
>
>Of course, it's possible that it wasn't necessary to do this but I wanted to
>anyhow.
>
>I'm not sure if posting code is ok here but I'm going to go out on a limb
>and post it anyways.
>
>#macro hexRGB2povRGB(RGB)
>        #local R = RGB.red;
>        #local G = RGB.blue;
>        #local B = RGB.green;
>        #local povR = (R / 2.55) / 100;
>        #local povG = (G / 2.55) / 100;
>        #local povB = (B / 2.55) / 100;
>        <povR,povG,povB>
>#end
>
>To use it, put it into a pigment statement like this:
>pigment { color hexRGB2povRGB(<255,255,255>) }
>
>Well, there you have it.

It's somewhat unnecessarily overcomplicated. POV can perform arithmetic
on colour vectors, so you can simply write

#macro hexRGB2povRGB(RGB)
 RGB/255
#end

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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