POV-Ray : Newsgroups : povray.general : a macro Server Time
1 Nov 2024 11:16:26 EDT (-0400)
  a macro (Message 1 to 3 of 3)  
From: Aeroslin
Subject: a macro
Date: 31 Oct 2004 01:10:00
Message: <web.418480e1dfacac47946614380@news.povray.org>
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.

Aeroslin


Post a reply to this message

From: Mike Williams
Subject: Re: a macro
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

From: Warp
Subject: Re: a macro
Date: 31 Oct 2004 04:42:07
Message: <4184b36f@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> >pigment { color hexRGB2povRGB(<255,255,255>) }

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

> #macro hexRGB2povRGB(RGB)
>  RGB/255
> #end

  Actually calling the macro is more complicated than doing the operation
yourself, like this:

pigment { rgb <255,255,255>/255 }

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

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