thinger-bars-and-bands


Information

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



Procedures

NetLogo Version: NetLogo 4.0

globals
[ ; ticks
]



patches-own
[ rrr ggg bbb ]

to setup
   ca
   generate-obstacles obstacle-layout obstacle-size obstacle-density obstacle-color
   
end

to go
end

to seek
end

to generate-obstacles [ layout factor density hue ] 
   if layout = 1
   [ ; plus on axis
     ask patches with
     [ ( on-y-axis and py-within factor  )
       or
       ( on-x-axis and px-within factor  )
     ]
     [ set pcolor hue ]     
   ]
   if layout = 2
   [ ; on axis bars
     ask patches with
     [ ( px-within ((abs pycor / max-pycor) * factor) and pxcor mod int (density * 100) = 0 )
       or
       ( py-within ((abs pxcor / max-pxcor) * factor) and pycor mod int (density * 100) = 0 )
     ]
     [ set pcolor hue ]
   ] 
   if layout = 3
   [ ; cross axis bars
     ask patches with
     [ ( px-within ((abs pycor / max-pycor) * factor ) and pycor mod (density * 100) = 0 )
       or
       ( py-within ((abs pxcor / max-pxcor) * factor ) and pxcor mod (density * 100) = 0 )
       
     ]
     [ set pcolor hue ]
   ] 
   tick
   ;ifelse layout > 3
   ;[ print (word "illegal layout: " layout ":" ticks ) ]
   ;[ print (word "layout ok: " layout ":" ticks ) ]
end     

to thinger
    every (1 / frame-rate * 60 )
    [ generate-obstacles (1 + int (2.99 * abs sin ( timer * 20 ))) (abs cos (timer * 100) ) (.01 * (2 + random (max-pxcor * .25))) (random 140)
      if diffuse? [ diffuse pcolor .5 ]
      if diffuse-rgb? [ diffuse-rgb ]
    ]   
end

to-report px-within [ limit ]
   report abs pxcor < limit * max-pxcor
end

to-report py-within [ limit ]
   report abs pycor < limit * max-pxcor
end

to-report on-x-axis
   report pycor = 0
end

to-report on-y-axis
   report pxcor = 0
end


to get-patch-rgb
   let rrggbb extract-rgb pcolor
   set rrr item 0 rrggbb
   set ggg item 1 rrggbb
   set bbb item 2 rrggbb
end

to set-patch-rgb
   set pcolor approximate-rgb rrr ggg bbb
end

to diffuse-rgb
   ask patches [ get-patch-rgb ]
   diffuse rrr .5
   diffuse ggg .5
   diffuse bbb .5
   ask patches [ set-patch-rgb ]
end



   

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download thinger-bars-and-bands --