Color Uniqueness Tester

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 3.1pre1 • Viewed 247 times • Downloaded 24 times • Run 0 times
Download the 'Color Uniqueness Tester' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


This model was used to generate the color chart in the NetLogo User Manual.

Note the trick of establishing an alternate coordinate system and then calculating with that instead of with pxcor and pycor, to make the math simpler.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [table]

patches-own [ x y ]  ;; alternate coordinate system
                     ;; (not the same as pxcor and pycor)

to setup
  clear-patches
  ;; 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 ]
  ;; draw the rightmost column of whites
  ask patches with [(x = 10) and (y >= 0) and (y <= 13)]
    [ set pcolor y * 10 + 9.9999 ]
  ;; draw the rightmost column of patch labels
  ask patches with [(x = 11) and (y >= 0) and (y <= 13)]
    [ set plabel word precision (y * 10 + 9.9999) 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 = 11
        [ set plabel "white = 9.999  " ] ]
  ;; all make the patch labels visible against background
  ask patches
    [ ifelse pcolor mod 10 >= 4
        [ set plabel-color black ]
        [ set plabel-color white ] ]
end 

to go
  clear-output
  set table n-values 1400 [extract-rgb (? / 10)]
  let index 0
  foreach table
    [ if position ? sublist table (index + 1) (length table) != false
        [ output-print index / 10
          output-print bytes extract-rgb (index / 10)
          let match (1 + index + position ? sublist table (index + 1) (length table)) / 10
          output-print match
          output-print bytes extract-rgb match ]
      set index index + 1 ]
end 

to-report bytes [rgblist]
  report map [round (? * 255)] rgblist
end 

to whites
  clear-output
  foreach n-values 14 [? * 10 + 9.9]
    [ output-print (word ? " " bytes extract-rgb ?) ]
end 

to blacks
  clear-output
  foreach n-values 14 [? * 10]
    [ output-print (word ? " " bytes extract-rgb ?) ]
end 

There are 3 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Color Uniqueness Tester Download this version
Uri Wilensky over 14 years ago Color Uniqueness Tester Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.