color-chart_2009


Information

Created with NetLogo version NetLogo 4.0.4
Running with NetLogoLite.jar version 404.


WHAT IS IT?


This model is a variation of the Models Library model that was used to generate the color chart in the NetLogo User Manual.
This version uses turtles to create black boxes around the white colors.

XML TAGS


<info>
<summary>A color chart</summary>
<copy>Copyright 2004,2009 James P. Steiner</copy>
</info>

Procedures

NetLogo Version: NetLogo 4.0.4

;;;; SUMMARY
;;   A minor variation of the standard NetLogo color chart
;;   COPYRIGHT
;;;;
;;;;
;;;;
;;;;
patches-own [ x y ]  ;; alternate coordinate system
                     ;; (not the same as pxcor and pycor)

to startup
   setup
end
   
to setup
  ca
  ;; make the background white and set up an alternate
  ;; coordinate system
  ask patches
    [ set pcolor white
      set x pxcor + max-pxcor - 5
      set y max-pycor - pycor - 1 ]
  ;; draw all the colors 0 to 139
  ask patches with [(x >= 0) and (x <= 9) and
                    (y >= 0) and (y <= 13)]
    [ set pcolor y * 10 + x
      set plabel int pcolor
    ]
  ask patches with [ x = 10 and y >= 0 and y <= 13 ]
      [ sprout 1
        [ set color 0
          set shape "square"
          set heading 0
          set size 4.5
        ]
      ]
  
  ;; draw the rightmost column of whites
  ask patches with [(x = 12) and (y >= 0) and (y <= 13)]
    [ set plabel (word precision (y * 10 + 9.9) 4 "   " )]
  ;; draw the color key on the left
  ask patches with [(x = -2) and (y >= 0)]
    [
      if y = int (blue / 10)      [ set plabel "blue" ]
      if y = int (brown / 10)     [ set plabel "brown" ]
      if y = int (cyan / 10)      [ set plabel "cyan" ]
      if y = int (gray / 10)      [ set plabel "gray" ]
      if y = int (green / 10)     [ set plabel "green" ]
      if y = int (lime / 10)      [ set plabel "lime" ]
      if y = int (magenta / 10)   [ set plabel "magenta" ]
      if y = int (orange / 10)    [ set plabel "orange" ]
      if y = int (pink / 10)      [ set plabel "pink" ]
      if y = int (red / 10)       [ set plabel "red" ]
      if y = int (sky / 10)       [ set plabel "sky" ]
      if y = int (turquoise / 10) [ set plabel "turquoise" ]
      if y = int (violet / 10)    [ set plabel "violet" ]
      if y = int (yellow / 10)    [ set plabel "yellow" ]
      set plabel (word plabel " = " (y * 10 + 5) " " )
    ]
  ;; add black and white in the top row
  ask patches with [y = -1]
    [ if x = 0
        [ set plabel "black = 0" ]
      if x = 12
        [ set plabel "white = 9.9     " ] 
   ]
  ;; all make the patch labels visible against background
  ask patches
    [ ifelse pcolor mod 10 >= 4
        [ set plabel-color black ]
        [ set plabel-color white ] ]
end

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download color-chart_2009 --