Box Drawing Example
Model was written in NetLogo 5.0.4
•
Viewed 1047 times
•
Downloaded 108 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
;; declare a global variable, halfedge, to be used when the box center is at (0,0) globals [halfedge] ;; setup procedure for case where point (0,0) is lower left corner of Box ;;note slider that sets the size of the box. to setup-corner ca ;; clear everything ask patches[ ;; if patches are between (0,0) to (0,edge)... if ( pxcor = 0 and pycor >= 0 and pycor <= edge ) [set pcolor red] ;; ... draws left edge in red ;; if patches are between (edge,0) to (edge,edge)... if ( pxcor = edge and pycor >= 0 and pycor <= edge ) [set pcolor red] ;; ... draws right edge in red ;; if patches are between (0,0) to (edge,0)... if ( pycor = 0 and pxcor >= 0 and pxcor <= edge ) [set pcolor red] ;; ... draws bottom edge in red ;; if patches are between (0,edge) to (edge,edge)... if ( pycor = edge and pxcor >= 0 and pxcor <= edge ) [set pcolor red] ;; ... draws upper edge in red ] end ;; setup procedure for case where point (0,0) is in the center of Box to setup-center ca ;; clear everything ;; set halfedge as edge divided by two. in case edge is an odd number, ;; halfedge get the integer value of the division. set halfedge int (edge / 2) ask patches[ ;; if patches are between (-halfedge,-halfedge) to (-halfedge,halfedge)... if (pxcor = (- halfedge) and pycor >= (- halfedge) and pycor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws left edge in blue ;; if patches are between (halfedge,-halfedge) to (halfedge,halfedge)... if ( pxcor = (0 + halfedge) and pycor >= (- halfedge) and pycor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws right edge in blue ;; if patches are between (-halfedge,-halfedge) to (halfedge,-halfedge)... if ( pycor = (- halfedge) and pxcor >= (- halfedge) and pxcor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws bottom edge in blue ;; if patches are between (-halfedge,halfedge) to (halfedge,halfedge)... if ( pycor = (0 + halfedge) and pxcor >= (- halfedge) and pxcor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws upper edge in blue ] 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 | |
---|---|---|---|---|
Box Drawing Example.png | preview | Preview for 'Box Drawing Example' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.