POV-Ray : Newsgroups : povray.general : smooth gradient color_map : Re: smooth gradient color_map Server Time
2 May 2024 02:02:57 EDT (-0400)
  Re: smooth gradient color_map  
From: omniverse
Date: 22 Jul 2017 00:30:00
Message: <web.5972d3fc6b1125dc9c5d6c810@news.povray.org>
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?  I'd prefer a solution which does not require (an array of)
> named colours.
>
> thank you, jr.

Thinking ahead here: You are welcome!
You will probably get the idea from my fast example. Funny thing, still took me
half hour to write and edit again and again! I wanted it to do stepped colors
too, and comment on parts.

Bob

P.S. you can ignore the "by bob", no need to keep that. :)

/* SIMPLE SPECIFIC NUMBER OF COLORS FOR A GRADIENT PATTERN by bob */

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

#declare EndColorCount=254; // or > BeginColorCount

#declare StepsCount=12; // 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 <(EndColorCount-It)/EndColorCount,0,It/EndColorCount>
  color rgb <(EndColorCount-It)/EndColorCount,0,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.