color schema

21 views
Skip to first unread message

Chris Harvey

unread,
Feb 11, 2020, 1:30:13 PM2/11/20
to GAMA
Hello everyone,

I have an issue that I think is easy, it's just that I'm having trouble with it.  I want to display using a specific color scheme, in this case I want the color schema to be a gradient of the number of shrimp agents in the cell and all the other cells to be white.  For the life of me, I cannot get the other cells to be white.  I get all sorts of other colors.  The gradient part of my code works fine, it's just the background cells that are not involved are not white.  This is my code:

reflex ShrimpDensity
{
Switch(ShrimpDensity_m)
 {
 match_between[1,5]
  {sDColor <- rgb((ShrimpDensity_m)/10*255,99,71);}
 match_between[5,10]
  {sDColor <- rgb((ShrimpDensity_m/10*255,99,71);}
 match_between[10,15]
  {sDColor <- rgb((ShrimpDensity_m/10*255,99,71);}
 match_between[15,20]
  {sDColor <- rgb((ShrimpDensity_m)/10*255,99,71);}
 match_between[20,25]
  {sDColor <- rgb((ShrimpDensity_m/10*255,99,71);}
 match_between[25,30]
  {sDColor <- rgb((ShrimpDensity_m/10*255,99,71);}
 match_between[30,100]
  {sDColor <- rgb((ShrimpDensity_m/10*255,99,71);}
 
 default
 {
   sDColor <- rgb((ShrimpDensity_m/10*255,255,255);
 }

 sDColor <- rgb((ShrimpDensity_m)/10*245,245,245);

}



aspect s
{ draw shape color: sDColor border:#gray at: {location.x, location.y,location.z};


Benoit Gaudou

unread,
Feb 11, 2020, 10:27:42 PM2/11/20
to gama-p...@googlegroups.com
Dear Chris,

Few comments:
- I do not understand why you have so many match_between cases, with always the same color value assigned to the sDColor variable.
- I do not understand why you have all the match_between and the default , that assign the same color.

But the most important remark:
- I do not understand why you have the last line : " sDColor <- rgb((ShrimpDensity_m)/10*245,245,245);" : it will change the color of all the agents (and make the switch blocks useless).
So the expected behaviour of your code is that all the cells have a color depending on their ShimpDensity. and the cells without shrimps (ShrimpDenisty = 0) will have a color blue / cyan.

Cheers

Benoit

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/b394100f-6025-429f-8371-d965d33bda3f%40googlegroups.com.

Chris Harvey

unread,
Feb 11, 2020, 11:47:39 PM2/11/20
to GAMA
Hello Benoit,

To answer the first question, I am looking for gradients of a single color based on the density of the ShrimpDensity_m variable.  The second question...I think you found my mistake.  The default value should be the white.  You are correct on what the expected behavior is.  I want the colors to be a gradient of a single color based on the value of the ShrimpDensity and all other cells with ShrimpDensity = 0, would be white.  Let me remove that last line and try it again.  I'll let you know what happens.

Chris

You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/YzIjO3MLBwU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/CAD4GtYGHjUOjD_jUFBmxtMvHLRPe4%2BRxuwGTmake6F%2BvtMttOA%40mail.gmail.com.

Chris Harvey

unread,
Feb 12, 2020, 1:15:33 AM2/12/20
to GAMA
Dear Benoit,

Sometimes, I do not think very clearly.  You're right.  This is what fixed it to do exactly what I wanted.

reflex ShrimpDensity
{
switch (ShrimpDensity_m)
{
match_between[0.001,500]
{
sDColor <- rgb(ShrimpDensity_m*247,173,76);
}
default
{
sDColor <- rgb(255,255,255);
}
}
}

On Tue, Feb 11, 2020 at 9:27 PM Benoit Gaudou <benoit...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/YzIjO3MLBwU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/CAD4GtYGHjUOjD_jUFBmxtMvHLRPe4%2BRxuwGTmake6F%2BvtMttOA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages