|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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.
Post a reply to this message
Attachments:
Download 'pout.txt' (883 KB)
|
|
| |
| |
|
|
|
|
| |
| |
|
|
hi,
"esfoster" <nomail@nomail> wrote:
> 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. ...
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},
...
};
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.
<https://wiki.povray.org/content/Reference:Spline>
regards, jr.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"esfoster" <nomail@nomail> wrote:
> 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.
divide the radius of every sphere by that of the largest sphere, that gives a
value between 1 and very small. The range depends on the sphere variation. Use
the value you get as an index to pick a colour, as jr suggest from a spline.
or use one of the interpolation (lerp) macro's to find an index between 1 and
zero from the radii.
ingo
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"ingo" <nomail@nomail> wrote:
> divide the radius of every sphere by that of the largest sphere, that gives a
> value between 1 and very small. The range depends on the sphere variation. Use
> the value you get as an index to pick a colour, as jr suggest from a spline.
>
> or use one of the interpolation (lerp) macro's to find an index between 1 and
> zero from the radii.
>
> ingo
pigment {rgb <0, Index, 1-Index>}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Depending on how you want your intermediate colors to look, you can do the
> interpolation in different color spaces.
Just to expand on that and give you a better idea of what that looks like:
https://wiki.povray.org/content/User:Le_Forgeron#Colour_space_interpolation
https://stackoverflow.com/questions/13488957/interpolate-from-one-color-to-another
Post a reply to this message
|
|
| |
| |
|
|
From: kurtz le pirate
Subject: Re: Coloring spheres based on their specified size
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
kurtz le pirate <kur### [at] gmailcom> wrote:
> 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
Thank you to everyone who helped. I ended up making a Matlab script to
interpolate rgb triplets and applying them to my diameters after they were
sorted. Took some work but I loved the result.
Post a reply to this message
Attachments:
Download 'pout.txt' (130 KB)
|
|
| |
| |
|
|
|
|
| |