Random Cd color from a main base color

   2489   2   1
User Avatar
Member
61 posts
Joined: May 2017
Offline
Hi guys

So, if i have an attribute expression to manipulate the color (Cd) attribute
I want this attribute expression to create random colors but based on a random variations of a single color

So for instance if the main color i want is green
then i want the attribute expression to produce random shades of green
from the original green, so that i can have lime green, dark green, etc…

Thank you
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
You might try randomizing in an hsv color space. You can use the hsvtorgb() function to convert the random hsv value to rgb color.

For example in an attribexpression, you might create 3 expressions for attribute Cd:

  1. random(@elemnum)
  2. fit01(self, chv('min'), chv('max'))
  3. hsvtorgb(self)

A range of (0.25, 0.5, 0.1) to (0.35, 0.9, 0.6) gives green colors. the components are hue, saturation, and value.
User Avatar
Member
61 posts
Joined: May 2017
Offline
jsmack
You might try randomizing in an hsv color space. You can use the hsvtorgb() function to convert the random hsv value to rgb color.

For example in an attribexpression, you might create 3 expressions for attribute Cd:

  1. random(@elemnum)
  2. fit01(self, chv('min'), chv('max'))
  3. hsvtorgb(self)

A range of (0.25, 0.5, 0.1) to (0.35, 0.9, 0.6) gives green colors. the components are hue, saturation, and value.

It works beautifully jsmack

Thanks so much for such detailed technical explanation

Now I can have a truly diverse forest vegetation using just one plant instance with this trick

Thanks a lot jsmack
  • Quick Links