user2293224
user2293224

Reputation: 2220

How to display color on monitor in netlogo

In my simulation, turtles are divided into groups. Each group has name and color. Groups form and vanish dynamically. I want to display group information (name and color) on the monitor of netlogo. When i used color variable on monitor, it gives the value of color (in numeric). Could any one tell me how can i display the color, not the value of color on monitor?

Upvotes: 0

Views: 163

Answers (1)

drstein
drstein

Reputation: 1113

I don't think there is a primitive that you can use to match color values to color name. The problem of this matching is that, for example, colors with values of 52 and 52 are two different shades of the same primitive color: green. You can use shade-of? to check if a certain color is a certain shade of a primitive color. You can check color shades here.

An example of how you can use shade-of:

to-report getshade [col]

  if(shade-of? col black) [report "black"]
  if(shade-of? col gray) [report "gray"]
  if(shade-of? col white) [report "white"]
  if(shade-of? col red) [report "red"]
  if(shade-of? col orange) [report "orange"]
  if(shade-of? col brown) [report "brown"]
  if(shade-of? col yellow) [report "yellow"]
  if(shade-of? col green) [report "green"]
  if(shade-of? col lime) [report "lime"]
  if(shade-of? col turquoise) [report "turquoise"]
  if(shade-of? col cyan) [report "cyan"]
  if(shade-of? col sky) [report "sky"]
  if(shade-of? col blue) [report "blue"]
  if(shade-of? col violet) [report "violet"]
  if(shade-of? col magenta) [report "magenta"]
  if(shade-of? col pink) [report "pink"]

end

You can use this report: getshade pcolor and retrieve the primitive color name of your patch.

Something you should take in account: all colors values multiples of 10 are black but they belong to a different shade, so you may see a patch with a black color showing another color name. The same is for white: every color ending with .9 is white but they all belong to a different shades.

Upvotes: 1

Related Questions