POV-Ray : Newsgroups : povray.general : smooth gradient color_map : Re: smooth gradient color_map Server Time
2 May 2024 04:49:32 EDT (-0400)
  Re: smooth gradient color_map  
From: omniverse
Date: 22 Jul 2017 01:20:00
Message: <web.5972dfb26b1125dc9c5d6c810@news.povray.org>
"omniverse" <omn### [at] charternet> wrote:
> jr <cre### [at] gmailcom> wrote:
> >
> > 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?

Sorry, I blame my awful speed reading. I put the red first and blue last, not
the way you said there.

And guess I should have asked why "254" instead of the usual 0 to 255. Won't
matter really, you only need to change the numbers to what you want.

Below is the blue to red way, obviously only a switch around of the rgb elements
to do that. And complete 256 color gradation, of course, just to show that.
Hopefully I did this example correctly, since I am known for flawing the
simplist things... and fouling up complexities for sure.
:D

Bob

#declare BeginColorCount=0; // or zero and < EndColorCount

#declare EndColorCount=255; // or > BeginColorCount

#declare StepsCount=1; // number to increment by (1 is good too)

box { // apply to this shape
0.00001,0.99999 // unequalize surface and color map
pigment {
 gradient x // choose a directional axis
 //ramp_wave // default
 color_map {

  #for (It,BeginColorCount,EndColorCount,StepsCount)
  [
  It/EndColorCount, (It+StepsCount)/EndColorCount
  color rgb <It/EndColorCount,0,(EndColorCount-It)/EndColorCount>
  color rgb <It/EndColorCount,0,(EndColorCount-It)/EndColorCount>
  ]
  #end

 }
}
finish {
 ambient 1 emission 0 diffuse 0 // see it without light
}
 translate -0.5 // center on origin vector
 scale 2 // double unit size
 rotate <30,30,30> // change orientation
 translate <0,0,4> // move location
}


Post a reply to this message

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