POV-Ray : Newsgroups : povray.general : Coloring spheres based on their specified size : Re: Coloring spheres based on their specified size Server Time
18 May 2024 08:41:17 EDT (-0400)
  Re: Coloring spheres based on their specified size  
From: kurtz le pirate
Date: 2 May 2024 10:43:27
Message: <6633a68f@news.povray.org>
On 01/05/2024 15:03, esfoster wrote:
> Hello,
> 
> I have a set of spheres defined with x, y, z, and size.
> 
> I want to add a color to them based on their size. e.g larger particles green
> and smaller particles blue and there would be a gradient assigned to fill the
> particles in between.
> 
> I have tried gradients and functions but have not yet gotten it to work.
> 

What I would do :

* First of all : apply jr's recommendation.

* Then :
- find minimum and maximum radius values
- calc the interval for radii : dRad = rMax-rMin
- calc the difference from one color to other color :
  dCol = Color1 - Color2
- clac the ColorStep = dCol/dRad


* finally in the loop of all spheres :
- calc the color :
  theColor = Color1 + ColorStep*(AllSpheres[i][1]-rMin)
- draw it
  sphere {
    AllSpheres[i][0], // sphere position
    AllSpheres[i][1] // sphere radius
    pigment { color theColor }
  }



/just a thought. untested/

-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

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