image - Export part of the view in NetLogo -


i want to, given list of turtles, export part of view contains turtles image. being able export part of view specified set of boundaries solve problem. is, function export-view-of-turtles list-of-turtles or export-view-rectangle min-xcor max-xcor min-ycor max-ycor ideal.

obviously, solution works entirely in netlogo best, find unlikely: export-view function know of exports image of view @ all, , whole view. however, if there's plugin this, awesome.

my last resort export view , run script clips accordingly. if there isn't better solution, i'll this, , post script.

alright, kind of dirty, seems work. basically, below exports world state in temp file, records data turtles in question, resizes view based on distance of turtles center, recreates turtles recorded data, exports view, restores original world state. here's code:

to export-view-of-turtles [ filename the-turtles ]   let center-patch min-one-of patches [ sum [ (distance myself ^ 2) ] of the-turtles ]   let turtle-props [ (list        (- distance center-patch * sin towards center-patch) ; xcor relative center patch        (- distance center-patch * cos towards center-patch) ; ycor relative center patch        heading size shape label color   ) ] of the-turtles   let max-x max map [ first ? + item 3 ? ] turtle-props   let min-x min map [ first ? - item 3 ? ] turtle-props   let max-y max map [ item 1 ? + item 3 ? ] turtle-props   let min-y min map [ item 1 ? - item 3 ? ] turtle-props   let world-state-backup (word "temp-world-" date-and-time ".csv")   export-world world-state-backup   resize-world min-x max-x min-y max-y   foreach turtle-props [     crt 1 [       setxy first ? (item 1 ?)       set heading (item 2 ?)       set size (item 3 ?)       set shape (item 4 ?)       set label (item 5 ?)       set color (item 6 ?)     ]   ]   export-view filename   import-world world-state-backup   file-delete world-state-backup end 

example of use. given:

enter image description here

calling export-view-of-turtles "test.png" [ turtles in-radius 5 ] of turtle 85 gives:

enter image description here

notes:

  • this supports world wrapping.
  • it show given turtles. patches, drawing layer, , other turtles not shown. said, modified patches , other turtles shown.
  • as code uses import , export world (not recommended kind of thing), break in many corner cases.

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -