POV-Ray : Newsgroups : povray.general : colors map interpolation : Re: colors map interpolation Server Time
26 Nov 2022 04:10:42 EST (-0500)
  Re: colors map interpolation  
From: Bald Eagle
Date: 20 Nov 2022 12:50:00
Message: <web.637a680ff841873a1f9dae3025979125@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:
> Hello,
>
> Let's assume that we have a colors map :
> #declare MyColorMap = color_map {
>   [ 0.00 rgb < 1.00, 0.00, 0.00> ]
>   [ 0.50 rgb < 1.00, 1.00, 0.00> ]
>   [ 1.00 rgb < 0.00, 0.00, 1.00> ]
>   }
>
> Is there a way to recover the color for specific index ?
> Something that looks like : GetColor(MyColorMap, index)

Sure - I think you could take something like a gradient pigment pattern, apply
that color mapping to it, and then use that as a function.   Then you could pass
in a space coordinate with a vector component parallel to that gradient, and the
function would return the interpolated color vector as a result.
You would of course, have to write / generate 3 functions - one for the .r, .g,
and .b components.

https://wiki.povray.org/content/Reference:Color_Map

Alternatively, you could roll your own and use a spline function to do the
interpolation, in case there something special that the above can't handle.


Post a reply to this message

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