POV-Ray : Newsgroups : povray.general : Coloring spheres based on their specified size : Re: Coloring spheres based on their specified size Server Time
29 May 2024 07:45:02 EDT (-0400)
  Re: Coloring spheres based on their specified size  
From: Bald Eagle
Date: 1 May 2024 10:20:00
Message: <web.66324ebcd66fa13b959fb4725979125@news.povray.org>
Welcome to the forum.  :)


"jr" <cre### [at] gmailcom> wrote:

> suggest re-structuring your data, separate centres and radii.  eg.
> #declare spharr = array [N] {
>   array mixed [2] {<0.385010,0.768357,0.476123>,0.019470},
>   ...
> };

Defnitely agree with jr that an array is the way to go.
No need to use mixed, you can just do x, y, z, r - but whatever way suits your
needs best

> and a '#for()' loop to make the union of spheres from that.  then you can
> "re-use" the radius as spline point perhaps, to retrieve a corresponding colour.

Don't know why you need the union, but you should just color your spheres at
each instantiation by using a macro that performs a linear interpolation between
green and blue based on the range defined by the smallest and largest spheres in
the array.

Depending on how you want your intermediate colors to look, you can do the
interpolation in different color spaces.

So, you write a macro
#macro ColorLERP (radius)
....
#end

then you just loop through your array and do sphere {<x, y, z> r pigment
{ColorLERP (r)}}

Hope that makes sense and you can figure most of that out.   If not, maybe
someone can chime in or I can take another look later today.

- BE


Post a reply to this message

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