POV-Ray : Newsgroups : povray.general : Colors of the rainbow : Colors of the rainbow Server Time
30 Jul 2024 00:30:59 EDT (-0400)
  Colors of the rainbow  
From: ruy
Date: 12 Apr 2010 21:00:00
Message: <web.4bc3c1f5568629a3d9ac4bb10@news.povray.org>
Hello,

I'm trying to produce the colors of the rainbow inside a #while loop, but to no
avail so far. I need them to progress from red to violet, and I am using the
CHSV2RGB for the conversion, which I thought would make things easier. Still,
all I get is a constant red color in my blob.

Here is the code. The problem is in the blob with the loop (which produces an
ascending spiral):

#include "colors.inc"

camera{
 location < 0, 150, -1000 >
 look_at < 0, 20, 0.000 >
 angle 5.000
}

light_source{ <800,4000, 700> rgb 1 }

sphere {
  <0, 0, 0>, 1
  texture {
   pigment {
     gradient y
     color_map {
       [0.0 color rgb < 01.0, 01.0, 1.0 >]
       [0.0 color rgb < 01.0, 01.0, 1.0 >]
     }
   }
   finish { diffuse 0 ambient 1 }
  }
  hollow on
  no_shadow
  scale 30000
}

blob {
    threshold .0005

    #declare Cr = 0;
    #declare Mx = 2330;
    #declare Rd = 0.1;
    #declare Ap = 1;
    #declare As = 1;
    #declare Vl = 1;
    #while (Cr <= Mx)
        sphere { <0,0,0>, 1.3 ,1
                 translate <Cr*Ap*Rd*Rd,Cr*Vl*Rd*Rd*1.3, Cr*As*Rd*Rd>
                 rotate y*Cr*Vl
                 texture {
                         pigment{rgbft CHSV2RGB(<((Mx-Cr)/Mx), 1.0, 1.0>)}
                 }
        }
        #declare Cr = Cr + 1;
    #end
}
___________

My intention here is to produce an ascending spiral with seven turns; each turn
being of a color of the rainbow (or something close to that). The spiral ascends
alright, but the colors don't vary at all.

There's very little documentation on CHSV2RGB, and I found no examples of it in
action, so any help will be greatly appreciated.

Ruy (an extremely absent POVer since 1994, version 2.2)


Post a reply to this message

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