POV-Ray : Newsgroups : povray.advanced-users : Simple colour_map question : Re: Simple colour_map question Server Time
29 Jul 2024 02:30:44 EDT (-0400)
  Re: Simple colour_map question  
From: Christopher James Huff
Date: 15 Feb 2003 12:42:20
Message: <cjameshuff-BBAE17.12411515022003@netplex.aussie.org>
In article <3e4e5c2f@news.povray.org>,
 "Andrew Coppin" <orp### [at] btinternetcom> wrote:

> Suppose I declare a colour_map. Is there a way to read a colour out of the
> map? In other words, is there a way I can feed in a nindex value and find
> the corresponding colour?
> 
> The docs say I can fetch the colour of a point out of a texture, but what
> I'm asking for is one step simpler than that... Any ideas folks?

Untested, but:

#macro make_cmap_fn(CMap)
    #local CFn =
    function {
        pigment {function {x}
            color_map {CMap}
        }
    }
    function (tVal) {CFn(tVal, 0, 0)}
#end

#macro eval_cmap(T, CMap)
    #local CFn =
    function {
        pigment {function {T}
            color_map {CMap}
        }
    }
    (CFn(0, 0, 0))
#end


#declare CFn = make_cmap_fn(MyCMap)
#declare CVal = CFn(0.35);

#declare CVal = eval_cmap(0.35, MyCMap);

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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