POV-Ray : Newsgroups : povray.general : Question Server Time
16 Nov 2024 05:18:28 EST (-0500)
  Question (Message 1 to 5 of 5)  
From: portelli
Subject: Question
Date: 21 Oct 1998 12:41:20
Message: <362D820B.E2082522@pilot.msu.edu>
I'm fairly new to Povray.  Well I'm just actually trying to learn
it.  I'm trying to create a circle of spheres that change color.  I want
it to go from red to blue at the bottom of the loop.  Then from blue to
red.  So it all blends together.  Here is the code i came up with to do
this.  Is there an easier way?  This does not work completely yet I
can't get it to go back to red.

#declare Count = 0 ;
  #while(Count < 36)
      object {YellowSphere
                pigment{
                   #if(Count <= 18)
                        color < (1-.027*(2*Count)), 0, ((2*Count)*.027)>

                   #else

                        color < abs(1-((2*Count)*.027)), 0,
((Count)*.027) >

                   #end}
                rotate z*10*Count

                translate <0, 0, 2>

             }
      #declare Count = Count + 1 ;

  #end


Post a reply to this message

From: Matthew Bennett
Subject: Re: Question
Date: 21 Oct 1998 17:01:33
Message: <362e3d9d.0@news.povray.org>
Try this...

Replace:
>         #if(Count <= 18)
>              color < (1-.027*(2*Count)), 0, ((2*Count)*.027)>
>         #else
>              color < abs(1-((2*Count)*.027)), 0, ((Count)*.027) >

With:
          #if(Count <= 18)
                color <1-(0.0556*Count), 0, 0.0556*Count>
          #else
                color <0.0556*(Count-18), 0, 1-(0.0556*(Count-18))>


To get things more accurate, you could also try replacing the "0.0556" with
"(1/18)".
Hope that helps,

Matt


Post a reply to this message

From: Peter Popov
Subject: Re: Question
Date: 22 Oct 1998 23:08:01
Message: <362fe501.0@news.povray.org>
Since it is a circle you might want to try to union all spheres and apply a
radial pigment to them... you'll save memory too (one texture vs. many)

Peter


Post a reply to this message

From: coste
Subject: Re: Question
Date: 1 Feb 2001 17:45:46
Message: <3A79E6A0.AB097000@noos.fr>
pour ma part je le ferais comme ceci :
To copy and to run directly in ".pov" format.





#declare PosCam=4 ;
#declare Rep=0 ;


#declare camx=-4;
#declare camy=0;
#declare camz=4;
#declare dcamx=0;
#declare dcamy=0;
#declare dcamz=0;

#if (PosCam=1)
  light_source {<camx,camy, camz> rgb< 1, 1, 1>}
#end // du if

camera{ //________________________________
#switch(PosCam) //                        |
#case(1)              //de loin
 location <camx,camy,camz>
 look_at  <dcamx,dcamy,dcamz>
#break

 location <0, 10, 0>
 look_at  <0, 0, 0>
#break

 location <5, 0, 5>
 look_at  <0, 0, 0>
#break
#case(4)            //de dessus
 location <0, 0, -8>
 look_at  <0, 0, 0>
#break
#case(5)            //base du tronc
 location <5,5, 5>
 look_at  <0, 0, 0>
#break
#end
}//_______________________________________|

//____________________________________
light_source // (Principale)          |
  {<26,10, +9> rgb< 2, 2, 2>}
light_source // (diffuse1)
  {<0,0, 0> rgb<1,1,1>}
light_source // (diffuse2)
  {<-6,-10,-9> rgb<1,1,1>}
//____________________________________|

#if (Rep=1)

//#########################################################################################################################

sphere{ <4, 0, 0> 0.25 pigment {rgb <0,3,3>}}
sphere{ <0, 4, 0> 0.25 pigment {rgb <0,3,3>}}
sphere{ <0, 0, 4> 0.25 pigment {rgb <0,3,3>}}


box   // axe des X
{ <-20, 0, 0>< 20,  0.1, 0.25>
  pigment {rgb <1,0,0>}}

box   // axe des Y
{ <0, -30, 0><0.25,  30, 0.25>
  pigment {rgb <0,1,0>}}

box   // axe des Z
{ <0, 0, 20> <0.25,  0.1, -30>
  pigment {rgb <0,0,1>}}
#end
//****************************************
background {rgb <0.4,0.5,0.6>}   // ciel plus sombre
//------------------------Objets:---------------------------


#macro cercle(fin,nbsph)

 #declare pas=fin/nbsph;
 #declare dim=2.5
 #declare compt=0

object{union{
  #while (compt<=fin)
      #if (compt<(fin/2))
                 #declare bleu=(2*compt)/fin
                 #declare rouge=1-(2*compt)/fin
      #else
                 #declare bleu=2-(2*compt)/fin
                 #declare rouge=(2*compt)/fin-1
      #end
      sphere  {  <dim*cos(2*pi*compt/fin), dim*sin(2*pi*compt/fin), 0> 0.125
pigment {rgb<rouge,0,bleu>}}

      #declare compt=compt+pas;
  #end //---------- de While

 } // de union
 } // de object
#end //------------ de Macro plante


object {cercle(10,50) rotate <0,0,-90>}

//--------------------------------------------------fin code



>     I'm fairly new to Povray.  Well I'm just actually trying to learn
> it.  I'm trying to create a circle of spheres that change color.  I want
> it to go from red to blue at the bottom of the loop.  Then from blue to
> red.  So it all blends together.  Here is the code i came up with to do
> this.  Is there an easier way?  This does not work completely yet I
> can't get it to go back to red.
>
> #declare Count = 0 ;
>   #while(Count < 36)
>       object {YellowSphere
>                 pigment{
>                    #if(Count <= 18)
>                         color < (1-.027*(2*Count)), 0, ((2*Count)*.027)>
>
>                    #else
>
>                         color < abs(1-((2*Count)*.027)), 0,
> ((Count)*.027) >
>
>                    #end}
>                 rotate z*10*Count
>
>                 translate <0, 0, 2>
>
>              }
>       #declare Count = Count + 1 ;
>
>   #end


Post a reply to this message

From: coste
Subject: Re: Question
Date: 1 Feb 2001 17:57:30
Message: <3A79E967.F851B3E5@noos.fr>
#macro cercle(nbsph)

 #declare fin=1
 #declare pas=fin/nbsph;
 #declare dim=2.5
 #declare compt=0

object{union{
  #while (compt<=fin)
      #if (compt<(fin/2))
                 #declare bleu=(2*compt)/fin
                 #declare rouge=1-(2*compt)/fin
      #else
                 #declare bleu=2-(2*compt)/fin
                 #declare rouge=(2*compt)/fin-1
      #end
      sphere  {  <dim*cos(2*pi*compt/fin), dim*sin(2*pi*compt/fin), 0> 0.125
pigment {rgb<rouge,0,bleu>}}

      #declare compt=compt+pas;
  #end //---------- de While

 } // de union
 } // de object
#end //------------ de Macro plante









object {cercle(100) rotate <0,0,-90>}

//-------------------------------- fin


it's better like this...




> Try this...
>
> Replace:
> >         #if(Count <= 18)
> >              color < (1-.027*(2*Count)), 0, ((2*Count)*.027)>
> >         #else
> >              color < abs(1-((2*Count)*.027)), 0, ((Count)*.027) >
>
> With:
>           #if(Count <= 18)
>                 color <1-(0.0556*Count), 0, 0.0556*Count>
>           #else
>                 color <0.0556*(Count-18), 0, 1-(0.0556*(Count-18))>
>
> To get things more accurate, you could also try replacing the "0.0556" with
> "(1/18)".
> Hope that helps,
>
> Matt


Post a reply to this message

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