Color Chart Example
Model was written in NetLogo 5.0.4
•
Viewed 1438 times
•
Downloaded 129 times
•
Run 1 time
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Click to Run Model
;; The origin patch is (0,0) is located where the color 0 appears; ;; this helps keep the math relatively simple. Unfortunately there's ;; no way to make pycor increase as we go down instead of up. So ;; instead, we use the trick of using negative y coordinates: row ;; 0 has a pycor of 0, row 1 has a pycor of -1, row 2 has a pycor ;; of -2, and so on. to setup ca ;; make the background white ask patches [ set pcolor white ] ;; draw all the colors 0 to 139 ask patches with [(pxcor >= 0) and (pxcor <= 9) and (pycor <= 0) and (pycor >= -13)] [ set pcolor -10 * pycor + pxcor set plabel int pcolor ] ;; draw the rightmost column of whites ask patches with [(pxcor = 10) and (pycor <= 0) and (pycor >= -13)] [ set pcolor -10 * pycor + 9.9 ] ;; draw the rightmost column of patch labels ask patches with [(pxcor = 11) and (pycor <= 0) and (pycor >= -13)] [ set plabel word precision (-10 * pycor + 9.9) 4 " "] ;; draw the color key on the left ask patches with [(pxcor = -2) and (pycor <= 0)] [ if pycor = int (blue / -10) [ set plabel "blue" ] if pycor = int (brown / -10) [ set plabel "brown" ] if pycor = int (cyan / -10) [ set plabel "cyan" ] if pycor = int (gray / -10) [ set plabel "gray" ] if pycor = int (green / -10) [ set plabel "green" ] if pycor = int (lime / -10) [ set plabel "lime" ] if pycor = int (magenta / -10) [ set plabel "magenta" ] if pycor = int (orange / -10) [ set plabel "orange" ] if pycor = int (pink / -10) [ set plabel "pink" ] if pycor = int (red / -10) [ set plabel "red" ] if pycor = int (sky / -10) [ set plabel "sky" ] if pycor = int (turquoise / -10) [ set plabel "turquoise" ] if pycor = int (violet / -10) [ set plabel "violet" ] if pycor = int (yellow / -10) [ set plabel "yellow" ] set plabel (word plabel " = " (-10 * pycor + 5) " ") ] ;; add black and white in the top row ask patches with [pycor = 1] [ if pxcor = 0 [ set plabel "black = 0" ] if pxcor = 11 [ 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 ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Color Chart Example.png | preview | Preview for 'Color Chart Example' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.