Skip to main content

4.9) Working With Graphics


NetLogo represents colours in different ways. A colour can be number in the range 0 to 140, with the exception of 140 itself. Some of the colors have names. (You can use these names in your code.) Every named colour except black and white has a number ending in 5. On either side of each named colour are darker and lighter shades of the colour. 0 is pure black. 9.9 is pure white.

You can use the primitive scale-color to set a colour according to a certain variable (number) and a defined range.

scale-color color number range1 range2
to paint-patch
   ifelse own-stress-level >= 100
      [set pcolor scale-color red own-stress-level 300 100]
      [if own-stress-level > 10 [set pcolor scale-color green own-stress-level 0 100] ]
end