Box Drawing Example

Box Drawing Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

code example 

Tagged by Reuven M. Lerner almost 12 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 1047 times • Downloaded 108 times • Run 1 time
Download the 'Box Drawing Example' modelDownload this modelEmbed this model

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.

Uploaded by When Description Download
Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky almost 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 14 years ago Box Drawing Example Download this version
Uri Wilensky over 14 years ago Box Drawing Example Download this version

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.