POV-Ray : Newsgroups : povray.general : smooth gradient color_map : Re: smooth gradient color_map Server Time
2 May 2024 05:48:38 EDT (-0400)
  Re: smooth gradient color_map  
From: kurtz le pirate
Date: 22 Jul 2017 06:55:59
Message: <59732f3f$1@news.povray.org>
Le 22/07/2017 à 00:28, jr a écrit :
> hi,
>
> can someone please point me to a color_map example which provides a
> smooth blend/gradient from (ideally) blue at 0 to red at 1 in 254
> increments?  I'd prefer a solution which does not require (an array of)
> named colours.
>
> thank you, jr.
>

You can try this :


// --- build colors map ---------------------------------
#declare colorStart = <1.00, 0.00, 0.00>;  // Red
#declare colorEnd = <0.00, 0.00, 1.00>;	   // Blue
#declare colorDelta = colorEnd - colorStart;

#declare nStep = 64; // or others values
#declare colorStep = colorDelta/(nStep);

#declare myMap = color_map {
#declare index = 0;
#while (index <= nStep)
	#declare c = colorStart + index*colorStep;
	#declare s = index/nStep;
	[ s rgb c]
	#declare index=index+1;
#end
}


// --- use colors map --------------------------------
box {
   <0, 0, 0>,< 5, 5, 100>
   pigment {
     gradient z
     color_map { myMap }
     scale <1,1,100>
     }
   }



-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

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