Creating many shades of colors for your Agents

9 views
Skip to first unread message

James Steiner

unread,
Jun 27, 2022, 3:26:08 PM6/27/22
to netlogo-users, Unruh Lee
As mentioned in another thread, below is a link to a demo in the modeling commons that shows two ways of generating colors for large numbers of agents. The original code was lost, but is recreated here.


The demo is runnable in the browser.

Here is the code for one of the methods.

This reporter converts a number (like a WHO number) into a NetLogo color, alternating between dimmer and brighter versions of the basic colors, with the difference increasing in intensity as the number increases.

to-report deep-color-1 [ value ]
  report (
    red + 10 * (value mod 13) ;; 13 base netlogo colors (not gray)
    ;; shift up or down
    +  .5 * ( (int (value / 13)) mod 2 * 2 - 1) ;; alternate -1, +1
    ;; increase difference (gets brighter and darker)
    * (1 + int ( value / ( 2 * 13 )))
    )
end
Reply all
Reply to author
Forward
0 new messages