NetLogo version NetLogo 4.1beta1
Running with NetLogoLite.jar version 411.
NetLogo Version: NetLogo 4.1beta1
globals [ old-style old-depth old-tint old-hue old-wave-width ] to startup setup end ;; to enable selection of a random style, ;; report the list of pre-defined style names in chooser control ;; (to maintain: after updating chooser control, copy contents of control ;; then paste to replace list in square brackets) to-report styles report [ "flat" "checked" "dappled" "gradient-horizontal" "gradient-h-dithered" "gradient-vertical" "gradient-v-dithered" "gradient-diagonal" "gradient-d-dithered" ] end to setup ca set style one-of styles end to execute setup-background style end ;; applies a background style selected by number or by name ;; "styles" reporter reports the list of legal style names to setup-background [ #style ] let base-color hue + tint ;; create command to execute style on patches let style-command (word "ask patches [ set pcolor " #style " base-color depth ]" ) ;; execute the command run style-command ;; note that if you just wanted to apply a particular style ;; (rather than allowing for selection among different styles) ;; you would just run the style command directly: ;; e.g.: ask patches [ set pcolor checked base-color depth ] end ;; helper reporters to scale pxcor and pycor to values between 0.0 and 1.0 to-report gx report ( ( pxcor - min-pxcor ) / world-width ) end to-report gy report ( ( pycor - min-pycor ) / world-height ) end to-report randomness report ( .1 * ( 1 - random 3 )) end ;; report the pcolor for "this" patch using a particular style to-report flat [ #hue #diff ] report #hue end to-report checked [ #hue #diff ] report #hue + #diff * ( ( pxcor + pycor ) mod 2 ) end to-report dappled [ #hue #diff ] report #hue + random-float #diff end to-report gradient-horizontal [ #hue #diff ] report #hue + #diff * gx end to-report gradient-vertical [ #hue #diff ] report #hue + #diff * gy end to-report gradient-diagonal [ #hue #diff ] report #hue + .5 * #diff * (gx + gy) end to-report gradient-h-dithered [ #hue #diff ] report #hue + #diff * gx + randomness end to-report gradient-v-dithered [ #hue #diff ] report #hue + #diff * gy + randomness end to-report gradient-d-dithered [ #hue #diff ] report #hue + #diff * .5 * (gx + gy) + randomness end ;; used to obtain appropriate minimum and maximum values for the tint slider to-report min-tint report precision -4.9 1 end to-report max-tint report precision ( 4.9 - depth ) 1 end to randomize ;; randomizes the display settings let tint-span max-tint - min-tint set hue 5 + 10 * random 13 set depth precision (.5 + .1 * random 42) 1 set tint precision (min-tint + precision ( random-float tint-span ) 1) 1 set style one-of styles end to-report control-monitor ;; monitors the values of the controls ;; updates the display using the new settings every 6 [ if auto-change? [ randomize ] ] if-else depth != old-depth or style != old-style or tint != old-tint or hue != old-hue [ set old-depth depth set old-style style set old-tint tint set old-hue hue execute tick report "changed" ] [ report (word "monitoring " (item ((floor timer) mod 3 ) [ "." ".." "..." ]) ) ] end to-report hue-name report item floor ((hue - 5) / 10) [ "red" "orange" "yellow" "brown" "" "" "" "" "" "" "" "" "" "" "" ] end
View or download the complete model file (to download: right-click, save-link-as):
-- Download background-styles_2009 --